"Changhsu P. Liu" wrote:
> 
> I have a property lis like the one below:
> aList = [a:88, b:22, c:34]
> Sort only sorts the property name not the value it has. I have the
> following handler to create another list that extract the value and sort
> the new list and then combine the 2 together in a new list that is sorted
> based on the value.
> 
> on sortByValue inputList, outputList
>    valueList = []
>    outList = [:]
>    repeat with temp in inputList
>      add valueList, temp
>    end repeat
>    sort valueList
>    repeat with temp in valueList
>      prop = getOne(folderList, temp)
>      addProp outputList, prop, temp
>    end repeat
>    put "outputList = " && outputList
>    outputList = outList
> end
> 
> It appears to work but I don't know what to do if there are 2 properties
> with the same value with my method. Just wonder if there is a better and
> quicker way to do this?

Hmmm... work with a .duplicate() of inputlist and loop on each value, as
you find them, delete them from that copy of the inputlist, when there
aren't any more of them move on to the next value.

> Also, how do I make whatever I type as "outputList" to become a global so
> it can recognized by others?
> 
> for example:
> if I use sorByValue (folderList), (newFolderList), then there would be
> global variable named newFolderList generated and the rightly sorted list
> would be in newFolderList.

Instead of declaring a global on the fly, I would make sortByValue
return the value of outputList by ending sortByValue with:

  return outputlist
end

 and then call it like this:

global gNewFolderlist
gNewFolderlist = sortByValue (folderList)


-- 
Carl West    [EMAIL PROTECTED]
617.262.8830 x246    
--------------------
To gain face, give it
To lose face, try to save it 
Or take it away 
                   - F. Eysenkopf

[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/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