Created
December 9, 2017 21:51
-
-
Save rafaeltab/08c0ed10d7f9dd5f1c9a76c6eb967a83 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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