Sort a %Library.ListOfObjects

I have a list of %Library.ArrayOfObjects . Each of list elements has some properties. I have to sort list by one of its objects properties. Is there a predefined method to doing that? (quicksort maybe?)

Vote up!
Vote down!

Rating: 0

Comments: 1 Views: 80

Comments

To mark your question as "answered" on Developer Community,
please click the checkmark alongside the answer you (as author of the question) accept.

Vote up!
Vote down!

Rating: 0

3 answers

Answer

Hi,

no. There aren't any library methods for that. It should be simple enough to implement a fairly generic quicksort you can re-use.

cheers,
Fab

Vote up!
Vote down!

Rating: -1

Answer

given the property you want to sort is unique and suitable as key for your array you may get the expected result.

set key=obj.sortproperty
set tSC=myArray.SetAt(obj, key)
Vote up!
Vote down!

Rating: 1

Answer
  1. Copy them into new array with keys = target property value. Iteration over this new array would be ordered as desired. Or when you set your array initially you can set keys = target property value.
  2. Another option is to order by local. Set some local with subscript = target property value, and local value as an oref. Then iterate over the local - you'll get ordered orefs.
Vote up!
Vote down!

Rating: 0

Log in to answer