I have some data in my SQL database like
- 1 Group 1
- 2 Group 1
- 11 Group 1
- 1 Group 2
- 1 Group 11
And I am querying like
String sortOrder = WiSeGroupContract.ColumnEntry.COLUMN_NAME_NAME + " COLLATE NOCASE";
contentResolver.query(WiSeGroupContract.ColumnEntry.CONTENT_URI,
null,
null,
sortOrder,
from,
limit);
And I am getting the output like
- 1 Group 1
- 1 Group 11
- 1 Group 2
- 11 Group 1
- 2 Group 1
but I wanted to like this
- 1 Group 1
- 1 Group 2
- 1 Group 11
- 2 Group 1
- 11 Group 1
The sorting based on the number in the string. It should be in alphabetical and also in ascending order of numbers.
in iOS, the database sorting will give the required output.
if(!sortDescriptors)
{
sortDescriptors = [NSArray arrayWithObject:[[NSSortDescriptor alloc] initWithKey:EntityAttributeName ascending:YES]];
}
[self groupWithPredicate :predicate sortDescriptors :sortDescriptors start :start limit :limit];
So is there any mechanism available for this? Or after fetching data, do I need to sort again?
How are they fetching data very much fast than android from the database with this sorting mechanism?