Re: SortBy + Sort Strings with apo.marks + CharacterCode
- To: mathgroup at smc.vnet.net
- Subject: [mg118276] Re: SortBy + Sort Strings with apo.marks + CharacterCode
- From: Peter <petsie at dordos.net>
- Date: Wed, 20 Apr 2011 04:26:13 -0400 (EDT)
- References: <iofs9a$s2b$1@smc.vnet.net>
Am 18.04.2011 01:14, schrieb Dr Andy D Kucar P2EE4 www.radio4u.com: > 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? > ... > > thank you, sincerely andy > Hi, Less[] is not defined for strings: "B"<"A"//FullForm returns unevaluated: Less["B","A"]. Use OrderedQ: In[1]:= Sort[{"January","February","March","April","May","June", "July","August","September","October","November","December", "English"}, OrderedQ[{##}]&] Out[1]= {"April","August","December","English","February","January"," July","June","March","May","November","October","September"} can't say anything about non-integer as character code ... Peter