Has anyone ever tried to replicate the alphabet sorting functionality you see in the list views? Any ideas on how to achieve this?
This functionality already exists on
List using the
Sorts the items in the list in ascending order.
In the following example, the list has three elements. When the list is sorted, > the first element is null because it has no value assigned while the second element has the value of 5:
List<Integer> q1 = new Integer; // Assign values to the first // two elements q1 = 10; q1 = 5; q1.sort(); // First element is null, second is 5 system.assertEquals(q1.get(1), 5);
Using this method, you can sort primitive types, SelectOption elements, and sObjects (standard objects and custom objects). For more information on the sort order used for sObjects, see List Sorting. You can also sort custom types (your Apex classes) if they implement the Comparable interface.
I think you're asking about how best to replicate the table sorting that happens when the user clicks a column header. If that's the case, you have basically two sorting options and three client-side table rendering options.