It looks like you're new here. If you want to get involved, click one of these buttons!
I'm working on a survey-based application that includes a mechanism for comparing people's compatibilities with the user's.
quick sort algorithm:
public static void qsort(People [] ppl, Integer [] a, Integer si, Integer ei){ //base case if(ei<=si || si>=ei){} else{ Integer pivot = a[si]; Integer i = si+1; Integer tmp; //partition array for(Integer j = si+1; j<= ei; j++){ if(pivot < a[j]){ tmp = a[j]; a[j] = a[i]; a[i] = tmp; i++; } } //put pivot in right position a[si] = a[i-1]; a[i-1] = pivot; //call qsort on right and left sides of pivot qsort(a, si, i-2); qsort(a, i, ei); } }
I have a rapid sort algorithm that efficiently sorts numbers from greatest to least, but I also need to sort an array of individuals alongside the array of integers (which is an array of people's compatibilities). How can I arrange the array of persons so that they correspond to their respective integer compatibility?