Sorting a MatrixCursor in Android

2k views Asked by At

I have a MatrixCursor like this:

final String[] matrix  = { "_id", "name", "price" };
MatrixCursor  data = new MatrixCursor(matrix);
data.addRow(new Object[] { i++, name, price });

I have several rows there. I'm looking for a method to sort my MatrixCursor:

  • according to name alphabetically AND
  • according to price from the lowest to the highest.
1

There are 1 answers

2
Hiral Vadodaria On

You will have to manually sort all the records first using ArrayList or so.And then you have to add them to MartixCursor.No other way AFAIK.