sort question

MisterX b.xavier at internet.lu
Fri Jun 3 14:21:02 EDT 2005


set the itemdelimiter to "."
sort lines of mylist numeric by item 2 of each
sort lines of mylist numeric by item 1 of each

or you decimal places will not be sorted right

but a simple

sort lines of mylist numeric by word 1 of each would sufice

;)

> -----Original Message-----
> From: use-revolution-bounces at lists.runrev.com 
> [mailto:use-revolution-bounces at lists.runrev.com] On Behalf Of Jim Ault
> Sent: Friday, June 03, 2005 20:10
> To: How to use Revolution
> Subject: Re: sort question
> 
> Greetings, jack
> 
> First point is that these are not numbers, so numeric has no meaning.
> These are text strings and are sorted as such.
> You also have some lines with trailing spaces.  You need to 
> clean these up some how to make the sorting work as you wish.
> 
> Try converting these strings to a number format by using a 
> technique of sorting 'each' line
> 
> This is a bit confusing when you first attempt it, but hang 
> in there because it is really a valuable tool.
> 
> 1) syntax>        sort lines of strList numeric by numberVersion(each)
> "each" tells Rev to send each line to a function to be 
> converted *before* sorting
> 
> 2) now the function that creates a number from the string 
> (for each line of the strList), and subsequently sorts that 
> number list, giving back the original strList in the new sort 
> order based on the numbers.
> 
> on sortFldSource
>   put fld "source" into tSource  --lines to sort
>   sort lines of tSource numeric by numberConvert(each)
>   put tSource into fld "destination"  --output for your 
> review end sortFldSource
> 
> function numberConvert pStrToConvert
>   if pStrToConvert is "" then
>     return ""
>   else 
>     set itemdel to  "."
>     if the last char of pStrToConvert is "-" then
>       put the last char of pStrToConvert into tSign
>       delete the last char of pStrToConvert
>     end if
>     put item 1 of pStrToConvert into tIntPart
>     put item 2 of pStrToConvert into tDecPart1
>     if the number of items in pStrToConvert > 2 then
>       put item 3 of pStrToConvert into tDecPart2
>     else
>       put "" into tDecPart2
>     end if
>     put tSign & tIntPart & "." & tDecPart1 & tDecPart2 into tReply
>     return tReply
>   end if
> end numberConvert
> 
> Thanks to jeanne a. e. devoto for this (each) form of the 
> "sort lines of"
> command.
> 
> Jim Ault
> Las Vegas
> 
> On 6/3/05 9:45 AM, "revinfo1155 at aol.com" <revinfo1155 at aol.com> wrote:
> 
> >  Greetings,
> >  
> >  I need a field to sort numerically and when I try it I get 
> the result below.
> > I checked the docs and experimented with the numberformat 
> without success.
> > Help!
> >  
> > jack
> > 
> >  
> > 
> > 1.101-
> > 10.101-
> > 10.201-
> > 10.301.1-
> > 10.351-
> > 10.401-
> > 10.501-
> > 11.101.1-
> > 11.151-
> > 2.101-
> > 2.301-
> > 20.101-
> > 3.101-
> > 4.101-
> > 4.991-
> > 5.101.1-
> > 5.151-
> > 5.201-
> > 5.301-
> > 5.351.1-
> > 5.401-
> > 5.451-
> > 5.501-
> > 5.651-
> > 5.701-
> > 6.101.1-
> > 6.201.1-
> > 6.301-
> > 6.401.1-
> > 7.101-
> > 7.151.1-
> > 7.201.1-
> > 7.251-
> > 7.401-
> > 7.501.1-
> > 8.101-
> > 8.301-
> > 9.101.1-
> > 9.351-
> > _______________________________________________
> > use-revolution mailing list
> > use-revolution at lists.runrev.com
> > http://lists.runrev.com/mailman/listinfo/use-revolution
> 
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 



More information about the use-livecode mailing list