Re: sorting words ?

2015-12-12 Thread Mark Waddingham
On 2015-12-12 13:48, Mark Waddingham wrote: 1) Find the ranges of the things you want to sort in the string. 2) Compute the new order of the substrings (from the ranges) based on the requested sort. 3) Rebuild the string replacing the original ranges in the original string with the reordered

Re: sorting words ?

2015-12-12 Thread Mark Waddingham
On 2015-12-12 02:39, Kay C Lan wrote: So the 3 possibilities are: 1) The example I gave in my last post. However many tabs and spaces would remain the same, they would be ordered, tabs before spaces, segments (words) would be placed between them. There would only be one white space between

Re: sorting words ?

2015-12-11 Thread Geoff Canyon
On Fri, Dec 11, 2015 at 3:28 AM, Mark Waddingham wrote: > I don't think I do agree with 'trying to do something sensible with the > whitespace' as I don't really see why that would be useful. If you break > down a string into a sequence of segments (I'll stop using word since

Re: sorting words ?

2015-12-11 Thread Geoff Canyon
On Fri, Dec 11, 2015 at 3:28 AM, Mark Waddingham wrote: > Hehe - perhaps best not to open that particular can of worms. For what its > worth, I'd actually class that behavior as an anomaly as it breaks the > logic of string lists - if there is a trailing delimiter, the

Re: sorting words ?

2015-12-11 Thread Kay C Lan
On Sat, Dec 12, 2015 at 7:24 AM, Geoff Canyon wrote: > > > I don't think I do agree with 'trying to do something sensible with the > > whitespace' as I don't really see why that would be useful. > > ​I agree that "sensible" is difficult to define here. OK, quickly off the

Re: sorting words ?

2015-12-11 Thread Mark Waddingham
On 2015-12-11 07:56, Kay C Lan wrote: On Thu, Dec 10, 2015 at 4:38 PM, Mark Waddingham wrote: The "word" chunk is not loosely implemented - it does precisely what it is meant to do. Which of course is the reason why the sort container command has no problem if you sort

Re: sorting words ?

2015-12-11 Thread Geoff Canyon
On Fri, Dec 11, 2015 at 8:39 PM, Kay C Lan wrote: > 2) The List is outputted with a single space between each segment. This > would mean that if there happened to be tabs or multiple spaces between > certain segments, these would be removed/converted. This is helpful. >

Re: sorting words ?

2015-12-10 Thread Mark Waddingham
On 2015-12-09 22:27, dunb...@aol.com wrote: The "word" chunk has always been loosely implemented, in that it can hardly be considered a truly delimited chunk at all, like an item or a line is. Even though it seems to have been included in the "family" of chunks. The "word" chunk is not loosely

Re: sorting words ?

2015-12-10 Thread Kay C Lan
On Thu, Dec 10, 2015 at 4:38 PM, Mark Waddingham wrote: > > The "word" chunk is not loosely implemented - it does precisely what it is > meant to do. > > Which of course is the reason why the sort container command has no problem if you sort by word on the right side of the

Re: sorting words ?

2015-12-09 Thread Mark Waddingham
On 2015-12-09 13:42, j...@souslelogo.com wrote: Hi Mark, I am probably missing something, but items can be separated by multiple itemdelimiters too, but nevertheless the sorting function works, as in this example : get "12,5,,4,10,,,11,24" sort items of it ascending numeric it returns

Re: sorting words ?

2015-12-09 Thread jbv
Hi Mark, I am probably missing something, but items can be separated by multiple itemdelimiters too, but nevertheless the sorting function works, as in this example : get "12,5,,4,10,,,11,24" sort items of it ascending numeric it returns ,,,4,5,10,11,12,24 and no compilation error... Best

Re: sorting words ?

2015-12-09 Thread jbv
ed as a sorting parameter; so why not use them also for sorting words in a variable ? What's the logic behind ? Thanks jb ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subs

Re: sorting words ?

2015-12-09 Thread Mark Waddingham
numeric by word 3 of each In that case, words are used as a sorting parameter; so why not use them also for sorting words in a variable ? What's the logic behind ? Words can be separated by multiple spaces, so the question here is that what would sorting the words of: the quick brown fox

Re: sorting words ?

2015-12-09 Thread Mike Bonner
It seems all you'd have to do is have sort include any trailing chars up to the next word along with word in question. " onetwo three." Spaces to the left of a word (at least as the first word) don't seem to delimit the word following, hence grabbing word 1 of the above string would

Re: sorting words ?

2015-12-09 Thread Mike Bonner
Ignore the extra puts in my preceding post of course. Forgot to clean up all of them after "seeing" how things were working. On Wed, Dec 9, 2015 at 8:28 AM, Mike Bonner wrote: > It seems all you'd have to do is have sort include any trailing chars up > to the next word along

Re: sorting words ?

2015-12-09 Thread jbv
Well, I don't want to keep this thread going forever but still... I do understand Mark's explanations, but still I don't understand this : since this is allowed (and returns the expected result) : get "the quick brown foxjumped over the lazy dog" set itemdel to space

Re: sorting words ?

2015-12-09 Thread Geoff Canyon
Note that words can also be delimited by tabs and crs, which doesn't allow for a simple substitution for sorting by items/lines, and would make for some odd results pretty much no matter what method you use. There is also the fact that this is six words: test this thing and this "thing right

Re: sorting words ?

2015-12-09 Thread Mark Waddingham
You explained the issue far better than me :) The proposed meaning is the most sensible 'consistent' interpretation I think as it preserves the list structure if not the original data entirely. Sent from my iPhone > On 9 Dec 2015, at 19:20, Geoff Canyon wrote: > > Note

Re: sorting words ?

2015-12-09 Thread dunbarx
y-goosey stuff. In only that way can you control the text you are dealing with. Craig Newman -Original Message- From: Mark Waddingham <m...@livecode.com> To: How to use LiveCode <use-livecode@lists.runrev.com> Sent: Wed, Dec 9, 2015 3:17 pm Subject: Re: sorting

Re: sorting words ?

2015-12-09 Thread [-hh]
There are delimiters that determine a class of chunks ("items" or "lines"). But there are also chunk types ("words" or "trueWords") that determine a class of delimiters. Would be very interesting to have a new kind of sort that enables to do sort things that are not definined by a certain fixed

Re: sorting words ?

2015-12-09 Thread Kay C Lan
On Wed, Dec 9, 2015 at 8:35 PM, Mark Waddingham 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 foxjumped over

Re: sorting words ?

2015-12-07 Thread Matt Maier
The first line in the doc here is "Use the *sort container* command to shuffle the order of lines or items in a container" http://docs.runrev.com/Command/sort-container Do you could use something like this: get "4 6 2

Re: sorting words ?

2015-12-07 Thread [-hh]
Being the first time three words shorter than Klaus :-))) get "4 6 2 8 5" set linedel to SPACE sort it numeric ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription

Re: sorting words ?

2015-12-07 Thread dunbarx
eric -Original Message- From: jbv <j...@souslelogo.com> To: How to use LiveCode <use-livecode@lists.runrev.com> Sent: Mon, Dec 7, 2015 11:31 am Subject: sorting words ? Hi list Just a quick question; the following returns a compilation error : get "4 6 2 8 5"

Re: sorting words ?

2015-12-07 Thread Klaus major-k
. yep, so why not use ITEMS? … get "4 6 2 8 5“ set itemdel to SPACE sort items of it ascending numeric … :-) > Craig Newman > > From: jbv <j...@souslelogo.com> > To: How to use LiveCode <use-livecode@lists.runrev.com> > Sent: Mon, Dec 7, 2015 11:31 am > Sub

sorting words ?

2015-12-07 Thread jbv
Hi list Just a quick question; the following returns a compilation error : get "4 6 2 8 5" sort words of it ascending numeric Is it because the sort function doesn't apply to words, or am I missing something ? Thanks jbv ___ use-livecode

Re: sorting words ?

2015-12-07 Thread [-hh]
> jbv wrote: > My problem is that I have words inside items... To have in such cases as usual "items" inside "lines" this works for me: set linedel to comma set itemdel to space ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit

Re: sorting words ?

2015-12-07 Thread jbv
>> jbv wrote: >> My problem is that I have words inside items... > > To have in such cases as usual "items" inside "lines" > this works for me: > > set linedel to comma > set itemdel to space > sure, but I actually have multiple lines with multiple items in each, and multiple words in each

Re: sorting words ?

2015-12-07 Thread jbv
Thank you all. Of course, I know how to use (and sort) items instead of words. My problem is that I have words inside items... But nevermind, I will use items inside arrays instead. jbv ___ use-livecode mailing list use-livecode@lists.runrev.com

Re: sorting words ?

2015-12-07 Thread Kay C Lan
nto tRepeats put the millisec into tStartTime repeat tRepeats times put empty into tOutput --SORTING WORDS USING REPLACE repeat for each line myLine in myListOfWordsInItemsInLines repeat for each item myItem in myLine replace space with comma in