Returns the original array with all the elements sorted incrementally
//Not the most efficient sorting algorithm in the world, but hey
ArrayList list = new ArrayList();
for (int i = 0 ; i < unsorted.length ; i++)
{
list.add(new Integer(unsorted[i]));
}
Collections.sort(list,
new Comparator()
{
public boolean equals(Object obj)
{
return false;
}
public int compare(Object o1, Object o2)
{
int i1 = ((Integer)o1).intValue();
int i2 = ((Integer)o2).intValue();
if (i1 < i2)return -1;
if (i1 == i2)return 0;
return 1;
}
});
int[] sorted = new int[unsorted.length];
for (int i = 0 ; i < list.size() ; i++)
{
sorted[i] = ((Integer)list.get(i)).intValue();
}
return sorted;