Dynamically adding sorted record IDs to a multi-select Lookup field

Dynamically adding sorted record IDs to a multi-select Lookup field

EDIT/Solution: instead "equals to" or ui:add, use .select (https://www.zoho.com/deluge/help/client-functions/select-deselect.html).
  1. IDs = Form1[Criteria].Lookup.getAll().distinct();
  2. IDsSorted = Form2[ID in IDs] sort by SortField;
  3. input.MultiSelectLookup.select(IDsSorted);

Original Problem:

I can dynamically add IDs (on User Input of another field) to a multi-select Lookup field, but I can NOT add sorted IDs.
  1. IDs = Form1[Criteria].Lookup.getAll().distinct();
  2. IDsSorted = Form2[ID in IDs] sort by SortField;
  3. input.MultiSelectLookup = ???
I've tried:
  1. input.MultiSelectLookup = IDsSorted.ID.getAll();
  2. input.MultiSelectLookup:ui.add(IDsSorted.ID.getAll()); (or append)
  3. for each id in IDs
    {
         input.MultiSelectLookup:ui.add(IDsSorted.ID.getAll()); (or append)
    }
None of the ui:add or ui:appends work.

The others work, but they add the values in the sort order of the field "Lookup" from Form1 above.

SO weird, and neither I nor Creator Support can figure it out.