function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sanjusanju 

How to sort all contacts/Accounts/opportunities returned by a query(is any in-built method exists?)

Hi all
i'm retrieving 200 contacts(as max. allowed) at a time, using a query. suppose if there are more than 1000 contacts, then how, one can retrieve those contacts in the same sorted order as they are displayed on this site. i'm getting those contacts in the same order as they were added(not sorted as this site do).
Is there any in-built method or technique exist?
Plz. help me soon.

Thanks for any suggestion!
DevAngelDevAngel
Hi sanju,

You will need to marshal your full recordset (that is all the records obtained from the original query and all the queryMores) into an array or map that you would than run a quicksort or some other sorting algorithm on.

There is no mechanism by which you can obtain a sorted result from sforce.
sanjusanju
Thanks Dave!

i just want to know how this site(sforce.com) displays those results in sorted order?
does it follow the same logic as you have mentioned ? let say, if a query fetchs a large number of records(>2K) then a huge amount of memory will be required to store and eventually sort them. is it acceptable where memory is a big constraint ?(small computing devices). There should be something, so that query can return results in sorted order.

sanju
DevAngelDevAngel
I agree. There should be something. Soon there will be.