Sort by date in a form

Sort by date in a form

Hello,

I have a Customer_Info form and an Inspection form. I have looked up the customer form where the assigned technician is assigned to that customer. The customer has an annual inspection which is due through out various times through the year.

I have found all of the sites where the loginuser is the assigned technician for the site.
then looked up all of the inspections that correspond to the customers account. I would like to sort the list by the inspection date, then put it into my drop down for the user to view.

Below is my code:

//---------------------------------------------------------
// Find all of the customers where the logged in user is
// the Assigned_Tech by default... Then add the sites to the list AssignedSites.
for each r in Customer_Info  [Assigned_Tech = User.ID]
{
    AssignedSites.add(r.ID);
}
//
//---------------------------------------------------------
// Load all of the Inspections for the logged in user by default.
//
for each x in AssignedSites
{
    xx = AssignedSites.size();
    ThisSite  =  Customer_Info  [ID == x];
    ThisInspection  =  Inspections  [ID == AssignedSites && (Next_Inspection_Due <= zoho.currenddate + input.Fire_Inspection_Range)];
    Upcoming_Inspection:ui.add(ThisSite.Site_ID + " - " + ThisInspection.Type_of_Inspection + " - " + ThisInspection.Next_Inspection_Due);
}
//
//---------------------------------------------------------
// Load Inspections with a count of the number of inspections
// that are in Upcoming_Inspections
input.Inspections = xx;

Thanks for any thoughts in advance,
Alan