|
jurz Novice
Joined: 22 Feb 2002 Posts: 48 Location: Latvia
|
Posted: Fri Sep 23, 2005 6:04 am
Sort integer list? |
Hi,
I got following information in variable:
111|112|77|78|93|95
I need to sort it in ascending order, any ideas or
hits how to do that?
Thanks in advance |
|
_________________ -Jurz |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Fri Sep 23, 2005 8:32 am |
Add padding 0's to each value so they all have the same length, commonly done with %repeat and %rightback. Then the %sort function will handle it correctly.
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
jurz Novice
Joined: 22 Feb 2002 Posts: 48 Location: Latvia
|
Posted: Fri Sep 23, 2005 9:09 am |
Not a bad idea, thanks
|
|
_________________ -Jurz |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Fri Sep 23, 2005 10:02 pm |
If you want to build the sort function yourself, you'll need two loops:
[code]
#loop 1,%numitems(@list) {
#loop 1,%numitems(@list) {
#if (%item(@list,%i) > %item(@list,%j)) {
#noop save one item
item = %item(@list,%i)
#noop copy %j item into %i item slot (duplication)
List = %replaceitem(%item(@list,%j),%i,@list)
#noop copy @item into %j item slot
List = %replaceitem(@item,%j,@list)
}
}
} |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
jurz Novice
Joined: 22 Feb 2002 Posts: 48 Location: Latvia
|
Posted: Sat Sep 24, 2005 10:44 am |
Thanks Matt, this was another thing to do but creating to simple functions
that add zeros and remove zeros are quite a bit more simple.
Thanks folks problem has been already solved. |
|
_________________ -Jurz |
|
|
|
|
|