I had a problem where I needed to find the largest amount of passengers in multiple cars/vans etc, so I got the totals from each vehicle and added them to a list, I then created this method to sort the list...
static List<int> SortList(List<int> tobesorted)
{
var j = 0;
int JP = 0;
int value1 = Convert.ToInt32(tobesorted[j]);
int value2 = Convert.ToInt32(tobesorted[JP]);
for (var i = 0; i < tobesorted.Count-1; i++)
{
for (j = 0; j < tobesorted.Count-1; j++)
{
JP = (j + 1);
value1 = Convert.ToInt32(tobesorted[j]);
value2 = Convert.ToInt32(tobesorted[JP]);
if (value2 > value1)
{
tobesorted[j] = value2;
tobesorted[JP] = value1;
}
}
j = 0;
JP = 0;
}
return tobesorted;
}
I don't understand is this is acceptable, and if not what methods are? It seems quick enough, I know of sorting algorithms, but haven't ever been forced to use any.