Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #1767

SortBy + Sort Strings with apo.marks + CharacterCode

From "Dr Andy D Kucar P2EE4 www.radio4u.com" <andy@radio4u.com>
Newsgroups comp.soft-sys.math.mathematica
Subject SortBy + Sort Strings with apo.marks + CharacterCode
Date 2011-04-17 23:14 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <iofs9a$s2b$1@smc.vnet.net> (permalink)

Show all headers | View raw


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 Å  Cc?? Cc Ð Šš \!\(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
Subject: 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!


Back to comp.soft-sys.math.mathematica | Previous | NextNext in thread | Find similar | Unroll thread


Thread

SortBy + Sort Strings with apo.marks + CharacterCode "Dr Andy D Kucar P2EE4 www.radio4u.com" <andy@radio4u.com> - 2011-04-17 23:14 +0000
  Re: SortBy + Sort Strings with apo.marks + CharacterCode "Sjoerd C. de Vries" <sjoerd.c.devries@gmail.com> - 2011-04-19 10:57 +0000

csiph-web