text sortType

Peter Haworth pete at lcsql.com
Tue May 28 16:27:48 EDT 2013


Yes,
Geoff's is definitely simpler, hadn't seen it when I made my post.  It did
give me the opportunity to finally use the custom function feature of the
sort command though!

I like the shortcut!

"After" is right in my code - I put the words into tKey, then the zeros,
then the number.  With your shortcut, the whole thing could be compressed
down to:

return word 1 to -2 of L &  char -6 to -1 of ("000000" & word -1 of L)   (I
think!)

Pete
lcSQL Software <http://www.lcsql.com>


On Tue, May 28, 2013 at 12:51 PM, Dar Scott <dsc at swcp.com> wrote:

> I think this and Geoff's are good!  This one is more general if you can
> come up with some sort of metric or sortvalue for each item/list.  Geoff's
> is simpler for this case.  The speed difference will depend on the length
> of the list.
>
> Shouldn't the zero be put 'before' instead of 'after' to force a numerical
> sort?
>
> Also, there is a shortcut.
>
> put char -6 to -1 of ("000000" & tKey) into tKey
>
> Dar
>
>
> On May 28, 2013, at 1:41 PM, Peter Haworth wrote:
>
> > The following worked for me (with apologies ofr any asterisks that may be
> > inserted into the script by my email client)
> >
> > It assumes there won;t be any numbers > 6 digits.
> >
> > *on* mouseUp
> >
> >   *sort* lines of field "Field" by reformatLine(each)
> >
> > *end* mouseUp
> >
> >
> > *function* reformatLine l
> >
> >   *local* tKey
> >
> >   *put* word 1 to -2 of item 1 of l into tKey
> >
> >   *repeat* 6-the length of word -1 of item 1 of l
> >
> >      *put* zero after tKey
> >
> >   *end* *repeat*
> >
> >   *put* word -1 of item 1 of l after tKey
> >
> >   *return* tKey
> >
> > *end* reformatLine
> >
> > Pete
> > lcSQL Software <http://www.lcsql.com>
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list