Skip to content

Instantly share code, notes, and snippets.

@rafaeltab
Created December 9, 2017 21:51
Show Gist options
  • Save rafaeltab/08c0ed10d7f9dd5f1c9a76c6eb967a83 to your computer and use it in GitHub Desktop.
Save rafaeltab/08c0ed10d7f9dd5f1c9a76c6eb967a83 to your computer and use it in GitHub Desktop.
import java.util.ArrayList;
public class Sort {
public ArrayList<Integer> sortInt(ArrayList<Integer> ints){
ArrayList<Integer> list = new ArrayList<Integer>();
int[] positions = new int[list.size()];
for(Integer intss : list) {
int pos = list.size();
for(Integer intsss : list) {
if(intss == intsss) {
}else if(intss >= intsss) {
pos++;
}else {
pos--;
}
}
positions[list.indexOf(intss)] = pos;
}
int[] sorted = new int[list.size()];
for(Integer intss : list) {
sorted[positions[list.indexOf(intss)]] = list.indexOf(intss);
}
ArrayList<Integer> sortedList = new ArrayList<Integer>();
for(Integer intss : list) {
sortedList.add(sorted[positions[list.indexOf(intss)]]);
}
return sortedList;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment