Prolog Quicksort using second element as a pivot
问题 I've been trying to learn prolog and I want to use the second element of a list as the pivot of a quicksort. I thought using [Head | [Pivot | Tail] ] as the input in the method would work, but then I was not sure where I could place "Head", the first element. like this: qsort([],[]):- !. qsort([Head|[Pivot|Tail]],Sorted):- split(Pivot,[Head|Tail],Less,Greater), qsort(Less,SortedLess), qsort(Greater,SortedGreater), append(SortedLess,[Pivot|SortedGreater],Sorted). split(_,[],[],[]). split(Pivot