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
GauravTrivediGauravTrivedi 

Sort given object in parent child fashion

I have given number of objects in set need to order them according to their lookup objects. For example, I have a set of following objects:
  1. Lead
  2. Account
  3. Campaign
  4. Contact
From the above object I have to find their refrence fields and then create a set from parent to their child, like this:
  1. Account
  2. Contact
  3. Lead
  4. Campaign
I am using Schema class to find their refrences but not able to sort then in the proper order.
Any help will be greatly appreciated. Thanks!
pconpcon
I'm not sure I really follow what you have and what you are trying to do.  You say you have "objects in set", are you saying you have them in apex like Set<sObject>?  Can you provide the code that you currently have to get them in the unordered way?  Then we can help you get them in the order you want.

NOTE: When including code please use the "Add a code sample" button (icon <>) to increase readability and make referencing code easier.
Grace StefanGrace Stefan
We lone get a insufficient years by our kids beforehand they choose that dressing like their mother forte be the world’s main fashion apparel (https://www.exporthub.com/apparel/) faux pas. So I am creation most of these years with these unconditionally gorgeous ways to clothing up composed.!!!  
 
steave james 6steave james 6
The shipping time for the Stranger Things Chrissy White Hoodie (https://www.pinesmax.com/products/stranger-things-s04-chrissy-hoodie) is 2-3 days.