MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: SortBy + Sort Strings with apo.marks + CharacterCode

  • To: mathgroup at smc.vnet.net
  • Subject: [mg118291] Re: SortBy + Sort Strings with apo.marks + CharacterCode
  • From: "ceo_www.radio4u.com" <ceo at radio4u.com>
  • Date: Wed, 20 Apr 2011 04:28:55 -0400 (EDT)

Gentlemen,

Thank you for your answers and help.
In this email, I'll try to answer the issues raised in the email below,
and explain further my points.

-----Original Message-----
From: DrMajorBob [mailto:btreat1 at austin.rr.com]
Sent: Monday, April 18, 2011 05:50
To: mathgroup at smc.vnet.net
Subject: [mg118291] [mg118257] Re: SortBy + Sort Strings with apo.marks + CharacterCode
#1>#2& makes no sense for Strings, because one string is not greater (or
less) than another.
Sort[
Within the Sort environment, > may be understood as a cardinality Order, CharacterCode number, etc.
Thus stating "a"<"b" may mean: the letter (character) "a" has smaller CharacterCode number than the character "b",
"April"< "May" is "sort wise" True, because "A"<"M", or,
Order["April", "May"]
1
or
Sort[{"May", "April"}]
{"April", "May"}

different forms (the first "a"<"b"  is NOT implemented, the other two are) for the same meaning, etc.
Sort[ ] does a good job sorting Strings (and Numbers), according to its own rules.

Sort[{345, "2", 1, "0", "("}] evaluates (and sorts) two different classes: Numbers and Strings
{1, 345, "(", "0", "2"}          any Number precedes a String, Number<String, etc.

One of my programs processes a large input matrix of up to 16 Columns x thousands of Rows,
The first Column consists of Strings; other Columns being mostly numbers;
Sort[ ] does it easily (details may come later).

However, new requirements (and new inputs) may require some flexibilities (modifications) of existing Sorting rules.
This is what I want to discus, ask, put on my wish list for next M.versions
]


How is "abcccdde ..." a sorting rule?
The true meaning has been lost in the translation (.nb > .doc > .txt plain text)
It should read
abc=E7\[CHacek]\[CAcute]d {d  z\&\[Hacek]} =D0e ...

this is a very interesting (possibly messy) subject,
which may be addressed later.


"b- d-(d) h- characters ?" is just incomprehensible.
In addition to an existing alphabet (more precisely abecedarium, since there is NO Greek (Cadmos, Akkad) letters alpha,
beta, yet),
One may need/wish to introduce her/his own glyphs/symbols/characters, like
=D0 (D-), d-, b-, h- == \hbar (Planck constant), etc., anything, and be able to place it/them to an appropriate place in
the computer memory,
i.e., assign to them an appropriate CharacterCode, to facilitate a correct Sort[ing]

How to do it?
Sincerely Andy

Bobby

On Sun, 17 Apr 2011 18:15:15 -0500, Dr Andy D Kucar P2EE4 www.radio4u.com
<andy at radio4u.com> wrote:

> Dear Mathgroup,
>
> Following on the original SortBy post and responses,
> I would like to expand with the following (Ver.4) funs
>
> In[17]
> Sort[{"January", "February", "March", "April", "May", "June", "July",
> "August", "September", "October", "November",
> "December", "English"}]
> Sort[{"January", "February", "March", "April", "May", "June", "July",
> "August", "September", "October", "November",
> "December", "English"}, #1 > #2 & ]
> ToCharacterCode[{"A2Z a2z ==C5  Cc?? Cc ==D0 ==A6==A8 \!\(Z\&?\)\!\(z\&?\"}]
>
> Out[17]
> {"April", "August", "December", "English", "February", "January",
> "July", "June", "March", "May", "November", "October",
> "September"}
> this is OK
>
> Out[18]
> {"January", "February", "March", "April", "May", "June", "July",
> "August", "September", "October", "November",
> "December", "English"}
> this is NOT ok; #1>#2 & has been ignored; the input has NOT been
> evaluated, i.e. sorted;
> why?
> How to Sort these String things?
>
> Out[19]
> {{65, 50, 90, 32, 97, 50, 122, 32, 197, 32, 268, 269, 32, 262, 263, 32,
> 208, 32, 352, 353, 32, 63425, 63433, 90, 63431,
> 780, 63424, 63425, 63433, 122, 63431, 780, 63424}}
> this ToCharacterCode conversion is OK;
> however, I have been using a text with some international characters,
> which require sorting rules different from the
> rule presented in Mathematica;
>
> For example, one would like to sort a particular String according to the
> following sorting rule: abcccdde ...
>
> One of (perhaps easiest) sorting possibilities would be, having been
> able to define a sorting rule,
> or redefine the CharacterCode and give it a real (rational) number,
> such as c (change in a program its CharacterCode from 269 to 99.1, or
> 99+269/1000, a CharacterCode number between c and
> d), etc.
>
> particularly problematic have been characters created via (Ctrl+& Esc hc
> Esc) construction
>
> how to create b- d-(d) h- characters ?
>
> thank you, sincerely andy
>
> -----Original Message-----
> From: graser
> Sent: Friday, April 15, 2011 02:57
> To: mathgroup at smc.vnet.net
> Subject: [mg118247] SortBy
>
> Dear Mathematica group,
>
> I have a simple question for you.
>
> Let's say there is a list like
>
> KS == {{300, 48, 2}, {500, 23, 5}, {120, 55, 7}, {40, 32, 1}};
>
> I want to sort it by second element.
>
> I can use
>
> Sort[KS, #2[[2]] > #1[[2]] &]
>
> It gives out like
>
> {{500, 23, 5}, {40, 32, 1}, {300, 48, 2}, {120, 55, 7}}
>
> But if I want to use SortBy, how to do that?
>
> SortBy[KS, ??]
>
> Thanks!
>
>
>


--
DrMajorBob at yahoo.com




  • Prev by Date: Re: Coloring a ListSurfacePlot3D with a n x 4 matrix
  • Next by Date: Re: solution
  • Previous by thread: Re: SortBy + Sort Strings with apo.marks + CharacterCode
  • Next by thread: Re: SortBy + Sort Strings with apo.marks + CharacterCode