Intelligent sorting: A bit of a poser
Jan Schenkel
janschenkel at yahoo.com
Thu Jul 1 11:59:45 EDT 2010
This did the trick in my quick test:
##
on mouseUp
put the text of field "OriginalList" into tText
sort lines of tText numeric by TrailingNumber(each)
sort lines of tText
put tText into field "SortedList"
end mouseUp
private function TrailingNumber pLine
local tNumber, tChar
repeat with tIndex = length(pLine) to 1 step -1
put char tIndex of pLine into tChar
if tChar is not an integer then exit repeat
put tChar before tNumber
end repeat
if tNumber is empty then put 0 into tNumber
return tNumber
end TrailingNumber
##
No idea how it performs on longer lists, though...
HTH,
Jan Schenkel
=====
Quartam Reports & PDF Library for Revolution
<http://www.quartam.com>
=====
"As we grow older, we grow both wiser and more foolish at the same time." (La Rochefoucauld)
--- On Thu, 7/1/10, FlexibleLearning <admin at FlexibleLearning.com> wrote:
> From: FlexibleLearning <admin at FlexibleLearning.com>
> Subject: Re: Intelligent sorting: A bit of a poser
> To: use-revolution at lists.runrev.com
> Date: Thursday, July 1, 2010, 6:46 AM
> Klaus, Colin...
>
> I should have been more clear! Looking for a generic
> solution to sorting
> arbitrary alphanumeric strings that have suffix numbers.
>
> For example...
>
> pic 10
> pic 2
> image1
> pic 1
> image10
> image2
>
> How do I sort them like this?
>
> image1
> image2
> image10
> pic 1
> pic 2
> pic 10
>
> /H
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage
> your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
More information about the use-livecode
mailing list