I’m working on a conference application where we want the sessions to be first grouped by time and then by room location. I have successfully sorted by one or the other in my ExpandableListActivity, but have been unsuccessful with both the primary and secondary sort.

(source: coreylatislaw.com)
Set up
- Custom content provider (extends ContentProvider)
- Custom list adapter (extends BaseExpandableListAdapter)
- Custom list activity (extends ExpandableListActivity)
Query
Cursor cursor = context.getContentResolver()
.query(uri,
ScheduleData.PROJECTION,
null,
null,
ScheduleData.SORT_ORDER);
Sort order
public static final String SORT_ORDER = TimeSlots.QUALIFIED_TIMESTART + " ASC"; // timeslots.timestart
Failed primary & secondary sort orders
public static final String SORT_ORDER = TimeSlots.QUALIFIED_TIMESTART + " ASC, " + Locations.QUALIFIED_NAME + " ASC"; // timeslots.timestart ASC, locations.name ASC
public static final String SORT_ORDER = TimeSlots.QUALIFIED_TIMESTART + ", " + Locations.QUALIFIED_NAME + " ASC"; // timeslots.timestart, locations.name ASC
The second clause seems to have no affect on the ordering. Is this a limitation of the ExpandableListActivity? Should I specify multiple sort order items differently?
Turns out that there was a comparator in the class that was overriding the sort order specified in the
ORDERBYclause. When using theORDERBYclauses above with out the comparator, I got the desired sorting. You can do it either way, but I’m killing the extra code and choosing theORDERBYclause.The comparator path: