2

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.
user
  • 86,916
  • 18
  • 197
  • 190
Martus0
  • 667
  • 1
  • 10
  • 16

1 Answers1

1

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.

Hiral Vadodaria
  • 19,158
  • 5
  • 39
  • 56
  • But every id, name and price are conected each other. When I'd like to sort names alpabetically each name has specified price. I have to look at one row like a wholeness. What is the best way to manage this task? – Martus0 Nov 08 '11 at 14:20
  • i have no idea for sorting by names but yes,you can sort prices,taking it into an array along with its id.and then you can add them in MartrixCursor.I don't know any other way.sorry! – Hiral Vadodaria Nov 09 '11 at 04:13