1. Length sorting.
Hy,
I don't think anyone is interested in this but what the # .
If you give a string to it, it sorts the strings by length
and returns it.
(It probably already exists, but I can't find it.)
BTW. It sorts from tiny/small to big/large.
("Belasting toegevoegde waarde" OR "By The Way" ????)
------------------------- LNGTSRT.E ------------------------------
include sort.e
global function sort_number(sequence string)
return custom_sort(1,string)
end function
global function sort_length(sequence string)
sequence lengths,order
lengths=repeat(0,length(string))
order=string
for a=1 to length(lengths) do
lengths[a]=length(string[a])
end for
lengths=sort_number(lengths)
for a=1 to length(order) do
for b=1 to length(lengths) do
if length(string[a])=lengths[b] then order[b]=string[a] end if
end for
end for
return order
end function
------------------------------------------------------------------
PQ
QC
(quistnet at yahoo.com)
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
2. Re: Length sorting.
Patrick Quist writes:
> return custom_sort(1,string)
I don't know where you get the 1 from.
The first argument to custom_sort() is
supposed to be a routine id. You haven't even called
routine_id() as far as I can tell, so the number is invalid
and you'll get an error message.
I'd like to warn people that the mapping from routines to
routine id numbers can change when you modify your code.
Never "hard-code" these numbers. They might even change from
one release of Euphoria to the next. You can assume that
they will be fairly small positive integers (or -1 for failure),
but that's about all.
Regards,
Rob Craig
Rapid Deployment Software
http://members.aol.com/FilesEu/
3. Re: Length sorting.
>Patrick Quist writes:
>> return custom_sort(1,string)
>
>I don't know where you get the 1 from.
Oops.
I forgot to change it.
It's supposed to be : return sort(string)
Sorry,
PQ
QC
(quistnet at yahoo.com)
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com