Post Reply 
Best way to sort one list based on another?
07-04-2015, 09:53 PM
Post: #5
RE: Best way to sort one list based on another?
Okay, here's a quick & dirty effort[1]:
Code:
EXPORT name := { "Bird", "Jordan", "O'Neal" };
EXPORT height := { 2.06, 1.98, 2.16 };

EXPORT SORTB(a,b)
BEGIN
  LOCAL c, i, p;
  c := EXECON("&2+CHAR(28)+&1", a, b);
  c := SORT(c);
  FOR i FROM 1 TO SIZE(c) DO
    p := INSTRING(c(i), CHAR(28));
    c(i) := MID(c(i), p+1);
  END;
  RETURN c;
END;

Call as: SORTB(name, height)

[1] It's not perfect - two people with the same height will be sorted by name as well.
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? - BruceH - 07-04-2015 09:53 PM



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