Post Reply 
Best way to sort one list based on another?
07-04-2015, 02:52 PM
Post: #2
RE: Best way to sort one list based on another?
I couldn't find any way to do it except the brute force method:

Code:

EXPORT sortlists(List1,List2)
BEGIN
 local i,j,temp, Size;
 Size:=size(List1);
 if Size <> SIZE(List2) then 
  print("lists are not the same size");
 end;
 for i from 1 to Size do
  for j from 1 to Size−1 do
   if List1(j) < List1(j+1) then
    temp:=List1(j);
    List1(j):= List1(j+1);
    List1(j+1):=temp; 
    temp:=List2(j);
    List2(j):=List2(j+1);
    List2(j+1):=temp;
   end;
  end;
 end;
 return {List1,List2};
END;

   

There is probably a better way, but this at least works.

Road
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Best way to sort one list based on another? - roadrunner - 07-04-2015 02:52 PM



User(s) browsing this thread: 2 Guest(s)