List Sorting with shell

Hi there,

I’ve picked the following code from a previous thread, but I just can’t get it to work:

set lst to {47, 7, 1, 8, 47, 2, 0, 36, 5, 92, 6, 47}
set {saveDelims, text item delimiters} to {text item delimiters, ASCII character (10)}
set x to do shell script "echo " & (lst as text) & "|sort -rn"
set text item delimiters to ASCII character (13)
set sortedList to text items of x
repeat with i from 1 to count sortedList
	set item i of sortedList to (item i of sortedList) as integer
end repeat
set text item delimiters to saveDelims
sortedList

As a result it only gives the first integer of the list but should give {92, 47, 47, 47, 36, 8, 7, 6, 5, 2, 1, 0}

I’m really keen to use this shell, any idea anyone?

Also, what’s the compatibility to Os’ regarding Shells?

Micha

Try something like this, Micha:

set l to {47, 7, 1, 8, 47, 2, 0, 36, 5, 92, 6, 47}
set d to text item delimiters
set text item delimiters to ASCII character 10
set l to paragraphs of (do shell script "echo " & quoted form of (l as text) & "| sort -rn")
set text item delimiters to d
repeat with i in l
	set i's contents to i as integer
end repeat
l
--> {92, 47, 47, 47, 36, 8, 7, 6, 5, 2, 1, 0}

Many thanks, it’s great.