Hi Slava,

Here is a simple solution using lingo only:

Create a new holder and set it to be sorted.

Loop through each of your items(that have prop1, prop2, prop3) and add them to a 'sortkey' property:
[
[#sortkey:"_abc_02_02", [#Prop1: "abc", #Prop2: "02", #Prop3: "02"]],
[#sortkey:"_abc_02_01", [#Prop1: "abc", #Prop2: "02", #Prop3: "01"]],
[#sortkey:"_xyz_02_01", [#Prop1: "xyz", #Prop2: "02", #Prop3: "01"]],
[#sortkey:"_abc_01_01", [#Prop1: "abc", #Prop2: "01", #Prop3: "01"]]
]


The first _ is in there cause props can't start with a number, in the case that you want to sort by prop 2 or 3 as the first sortitem.

The items should be sorted properly, and you can loop through the list to recreate the original list in a sorted format.

This works ok for medium to small lists... if you are doing anything huge keep in mind this solution is O(2n) complexity - it will ALWAYS have to traverse all the items in the list once to assign the key, and another time to write the new list back out.

Anyone have any other methods they use?

~Mathew

Slava Paperno wrote:
Is there an xplat Xtra that expands Directors limited ability to sort lists?

Or, can someone please advise me on how to implement this sort?

I have a linear list where the value of each item is a property list,
[  [#Prop1: "abc", #Prop2: "02", #Prop3: "02"],
   [#Prop1: "abc", #Prop2: "02", #Prop3: "01"],
  [#Prop1: "xyz", #Prop2: "02", #Prop3: "01"],
  [#Prop1: "abc", #Prop2: "01", #Prop3: "01"],  ]

I need to sort the outer linear list on the compound values of the three properties in 
the inner lists, so I get this:

[ [#Prop1: "abc", #Prop2: "01", #Prop3: "01"],
[#Prop1: "abc", #Prop2: "02", #Prop3: "01"],
[#Prop1: "abc", #Prop2: "02", #Prop3: "02"], [#Prop1: "xyz", #Prop2: "02", #Prop3: "01"] ]


If this were a database table with three fields and four records, I'd use a compound 
index, Prop1 + Prop2 + Prop3. How can I achieve the same result in Director MX?

The size of my lists and the number of properties in each list are quite modest, so 
peformance is not really an important factor.

Any advice will be appreciated.

Slava


[To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]

Reply via email to