Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #6673
| From | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Sorting strings |
| Date | 2011-11-24 11:55 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jalbcc$s9c$1@smc.vnet.net> (permalink) |
| References | <201111231207.HAA14969@smc.vnet.net> |
data = {"a1", "a2", "a20", "a12"};
SortBy[data, ToExpression[StringDrop[#, 1]] &]
{"a1", "a2", "a12", "a20"}
Bob Hanlon
On Wed, Nov 23, 2011 at 7:07 AM, Themis Matsoukas <tmatsoukas@me.com> wrote:
> Sorting this list of strings
>
> {"a1", "a2", "a20", "a12"} // Sort
>
> I get
>
> {"a1", "a12", "a2", "a20"}
>
> but I would like the numerals to be sorted as numbers, i.e., as
>
> {"a1", "a2", "a12", "a20"}
>
> Is this possible or do I have to rename "a1" into "a01" etc?
>
> Thanks
>
> Themis
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: Sorting strings Bob Hanlon <hanlonr357@gmail.com> - 2011-11-24 11:55 +0000
csiph-web