sorting words ?

Kay C Lan lan.kc.macmail at gmail.com
Wed Dec 9 22:41:08 EST 2015


On Wed, Dec 9, 2015 at 8:35 PM, Mark Waddingham <mark at livecode.com> wrote:

> Basically the answer to your question is simply that:
>
> a) It is not entirely obvious what 'sort the words of' should do.
>

Then why is it obvious to LC when you have this:

4 the quick brown  fox    jumped over     the lazy         dog --spaces
3    the    quick   brown    fox    jumped over    the lazy    dog --tabs
2 the      quick brown  fox    jumped over     the lazy         dog
--spaces and tabs
1 the      "quick brown  fox"    jumped over     the "lazy         dog"
 --quotes, tabs, spaces

sort lines of aboveVariable by word 4 of each

I read Geoff's response differently. One of LC's extremely powerful
features is it's ability to manipulate chunk expressions. Yes, 'word' is
often misunderstood and causes angst when it's LC definition is not
appreciated but once it is, the ability to quote text and have LC treat it
as a single word is very very powerful.

>
> b) The case of sorting a list of single space separated things is already
> available by fiddling with delimiters and using item/line chunks.
>

But as has been pointed out, that is not the sole LC word delimiter, so yes
if you need simple space delimited sorting, then yes it is possible to roll
your own, but if you want to sort a container by an LC word, consistent
with LC's 'sort... by word x of each', then I agree with jbv that an
extension to the current sort by container function to include word would
seem to be a logical and powerful addition to the arsenal - just try
achieving the same sort as above but without using 'word 4 of each' but by
'fiddling with delimiters and using item/line'.



More information about the use-livecode mailing list