Reputation: 20419
I use standard approach to display my database records in the ListView:
recordsCursor = mDb.query(DATABASE_BL_TABLE, new String[] {KEY_BL_ROWID, KEY_BL_SENDER, KEY_BL_ADDED}, null, null, null, null, KEY_BL_SENDER);
startManagingCursor(recordsCursor);
String[] from = new String[]{DbAdapter.KEY_BL_SENDER};
int[] to = new int[]{R.id.text1};
adapter = new SimpleCursorAdapter(this, R.layout.mylist_row, recordsCursor, from, to);
setListAdapter(adapter);
So, all records are sorted by KEY_BL_SENDER
.
I would like to implement the following sorting logic:
aa
, bb
, AA
, BB
will be displayed in the following order: AA
, aa
, BB
, bb
);** aa **
, ~bb~
, aa
, __BB__
will be displayed in the following order: aa
, ** aa **
, __BB__
, ~bb~
).How could I do it?
Upvotes: 1
Views: 171
Reputation: 15689
Let's join some known solutions:
Your query would look like:
SELECT ...
FROM ...
WHERE ...
ORDER BY
TRIM(KEY_BL_SENDER, "_*~ #$")
COLLATE NOCASE ASC;
Upvotes: 2