I need to sort my items depending on their price.
The price of each item is stored in a JSON array
I have created a 2d array to store the name and price
Something like this...
String [][] priceArray = new String [itemArray.length()] [2];
for(int i = 0; i < itemArray.length(); i++)
{
//put the item name in the first dimension
priceArray[i][0] = itemArray.getJSONObject(i).getString("name");
//put the item price in the second dimension
priceArray[i][1] = itemArray.getJSONObject(i).getString("baseprice");
}
//DEBUG TO SEE THE RESULTS
for(int i = 0; i < priceArray.length; i++)
{
Log.i("Item name : Item Price", priceArray[i][0] + " : " + priceArray[i][1]);
}
This works fine... but how can i sort the array by the price in the second dimension?
Is this even the best way to do this?