Page 2 of 3

Re: Slight issue with the sort command

Posted: Sun Nov 19, 2017 7:50 pm
by jacque
I see the confusion now. The sort does not use the word representation, if it did it could only sort up to ten. Shao Sean was joking about that. It only happened to work in this case because the first three lengths were incidentally correctly sorted by their alpha representations. It would fail in almost every other example.

Length() returns integers, and sorting numerically on those integers produces the correct result. The error was due to the English like nature of the language where our brain naturally fills in the missing pieces. As programmers we need to be careful about that.

Re: Slight issue with the sort command

Posted: Sun Nov 19, 2017 8:38 pm
by Mikey
I don’t understand why sort by length would also require a “numeric” specifier. That’s what I think needs to be explained in the docs

Re: Slight issue with the sort command

Posted: Sun Nov 19, 2017 9:34 pm
by bogs
jacque wrote: Sun Nov 19, 2017 4:36 pm
bogs wrote: Sun Nov 19, 2017 12:55 pm Oh, heh, I didn't think you had erased it my friend :D
If the post is the one about filtering out IDE stacks, it's there.
No, the post was a jokey post based on the tangents post after that post. I pm'd it to Craig instead, the only reason I was looking for a pm from the eraser was because for the life of me, I couldn't see what was in it that was bad enough to delete it. I can't learn from it if it just up and disappears like a fart in the wind, if you see (or don't) what I mean :D

Re: Slight issue with the sort command

Posted: Sun Nov 19, 2017 10:05 pm
by jacque
Mikey wrote: Sun Nov 19, 2017 8:38 pm I don’t understand why sort by length would also require a “numeric” specifier. That’s what I think needs to be explained in the docs
I don't undertand what you don't understand, I guess. :) Length() is a function, which could just as easily be a custom sort function that returns any data type. LC has no way of knowing how you want the order arranged unless you tell it. The default is an alpha sort, so without adding "numeric" to the sort command you will get an alpha sort:

1
10
111
...etc.

Which is what Craig got initially. I'm not sure how this would be different from any other sort command.

Edit: Imagine a list of times:

12:03
1:15
2:30
1:45

Sorting by default would sort these in alpha order. To get what you'd expect, you'd need to add "dateTime" to the sort command. "Sort lines of tList" returns alpha sorting, where "sort lines of tList dateTime" gives what you expect. Same thing, right?

Re: Slight issue with the sort command

Posted: Sun Nov 19, 2017 10:34 pm
by Mikey

Code: Select all

sort thatList by the length of item 1 of each
I need to add “numeric” why?

That we are continuing to have this discussion is exactly why the docs need a note.

Re: Slight issue with the sort command

Posted: Sun Nov 19, 2017 10:40 pm
by bogs
I used to think I knew this stuff, but at this point I think I am leaning towards what Mikey is saying. Clarification in the docs can't hurt, but it could probably help.

Re: Slight issue with the sort command

Posted: Sun Nov 19, 2017 10:51 pm
by dunbarx
Mike.

Constants are powerful and useful native elements. We could live without "comma", for example, but could not live without "quote".

So there are degrees of constant usefulness, and of their concomitant caveats in their use.

There is a counterintuitive glitch in using the constant "two, for example. This, to LC, is not a string of three chars. I have always found those particular ones to be dangerous and superfluous, and have never used any of them.

I do think it would be useful to supply an example in the dictionary showing the sorting, as I wrote above, "9,10,11" as ASCII and numeric, and what you get with either, and why.

Are the user notes still in existence? I do not see them anymore in v.8.They might be the best place to start.

Craig

Re: Slight issue with the sort command

Posted: Sun Nov 19, 2017 11:32 pm
by jacque
Mikey wrote: Sun Nov 19, 2017 10:34 pm

Code: Select all

sort thatList by the length of item 1 of each
I need to add “numeric” why?
Because you might in fact want all the 1s together. My list of times might be Bible verses or hospital rooms. The length of a string might not actually represent a measurement but rather something else. All sorting requires a qualifier, even if it is the default.

Re: Slight issue with the sort command

Posted: Mon Nov 20, 2017 12:35 am
by Mikey
I must have had a stroke. I am completely baffled by this conversation. The docs do not say you have to specify the sort type.

Re: Slight issue with the sort command

Posted: Mon Nov 20, 2017 1:57 am
by FourthWorld
Mikey wrote: Mon Nov 20, 2017 12:35 amThe docs do not say you have to specify the sort type.
True, and you don't. The docs say:
If you don't specify a sortType, the sortType is text.

Re: Slight issue with the sort command

Posted: Mon Nov 20, 2017 2:46 am
by dunbarx
We all use the term "text" somewhat loosely. The default is ASCII.

Try sorting this, plain vanilla:

Code: Select all

678
abc
@#$
Craig

EDIT:

Note that the caseSensitive will come into play if one wants to sort:
aaa
AAA
aaa
AAA
and have the ASCII 65 come before the ASCII 97.

Re: Slight issue with the sort command

Posted: Mon Nov 20, 2017 10:50 pm
by bwmilby
I’m not sure how/where a note would add to what is already there. Examples 2 and 3 are both numeric.

I do see a stray word after “text” as the default sortType in my copy. If in the repo I will submit a PR to correct.

Re: Slight issue with the sort command

Posted: Mon Nov 27, 2017 6:12 am
by bogs
bogs wrote: Sun Nov 19, 2017 12:13 am Wow, Craig, I'll send you a pm...
Heh, little did I know Craig needs to empty his inbox :mrgreen:

Re: Slight issue with the sort command

Posted: Mon Nov 27, 2017 7:32 am
by shaosean
Imagine all those deals on Russian goods he is missing out on..

Re: Slight issue with the sort command

Posted: Mon Nov 27, 2017 2:55 pm
by dunbarx
Heh, little did I know Craig needs to empty his inbox
Huh? My inbox is only half full.

Craig