text sortType

Dar Scott dsc at swcp.com
Tue May 28 17:01:26 EDT 2013


Great minds think alike!  That is the same return command I used!  Switching to capital L is a good idea, lower case l is hard to read.  

And you are right, I was so caught up in how I wanted to do it, I didn't see that yours should work, too, based on 'after'.

And you are right, this is a good place to consider the custom sorting value function.

I think had a slightly different interpretation of the format of the lines, but still...  This looks the same.

Dar




On May 28, 2013, at 2:27 PM, Peter Haworth wrote:

> 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
>> 
> _______________________________________________
> 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