From hb at stat.berkeley.edu  Fri Jan  8 01:12:46 2010
From: hb at stat.berkeley.edu (Henrik Bengtsson)
Date: Thu, 7 Jan 2010 16:12:46 -0800
Subject: [Rd] "Human-style" sort() of alphanum strings?
In-Reply-To: <59d7961d1001071550n6d9e0636gf797ecb2e584f53f@mail.gmail.com>
References: <59d7961d1001051534g43275960x258d0262db4f0ea1@mail.gmail.com>
	<971536df1001051548q60d92422q1c922d826cb12e4e@mail.gmail.com>
	<59d7961d1001071550n6d9e0636gf797ecb2e584f53f@mail.gmail.com>
Message-ID: <59d7961d1001071612t6624d02ao14bd7792686e0689@mail.gmail.com>

Thanks, and sorry - I missed those two "missing letter "ed" and though
you only refer to that URL for extra example code.  mixsort() does it
for me.

/H

On Thu, Jan 7, 2010 at 3:50 PM, Henrik Bengtsson <hb at stat.berkeley.edu> wrote:
> Follow up/bug:
>
> mixedsort() gets confused when there are periods in the string(s);
>
>> ? print(gtools::mixedsort("a"))
> [1] "a"
>> ? print(gtools::mixedsort("a."))
> [1] "a." NA
>> ? print(gtools::mixedsort("a.b"))
> [1] "a.b" NA ? ?NA
>> ? print(gtools::mixedsort("a.b."))
> [1] "a.b." NA ? ? NA ? ? NA
>> ? print(gtools::mixedsort("a.b.c"))
> [1] "a.b.c" NA ? ? ?NA ? ? ?NA ? ? ?NA
>> ? print(gtools::mixedsort("a.b.c."))
> [1] "a.b.c." NA ? ? ? NA ? ? ? NA ? ? ? NA ? ? ? NA
>
> Is the '.' trigger an incorrect interpretation of a number?
>
> /Henrik
>
> On Tue, Jan 5, 2010 at 3:48 PM, Gabor Grothendieck
> <ggrothendieck at gmail.com> wrote:
>> See mixedsort in gtools. ?Also on http://gsubfn.googlecode.com see
>> mixsort example in the section starting ### more examples
>>
>> On Tue, Jan 5, 2010 at 6:34 PM, Henrik Bengtsson <hb at stat.berkeley.edu> wrote:
>>> I know it is fairly easy to implement (though not always well
>>> defined), but is there an existing sort function out there that takes
>>> alphanum strings and sort them in a "human" fashion? ?For example,
>>> instead of:
>>>
>>> z1.doc z10.doc z100.doc z101.doc z11.doc z2.doc
>>>
>>> it should out put:
>>>
>>> z1.doc z2.doc z10.doc z11.doc z100.doc z101.doc
>>>
>>> (from http://www.davekoelle.com/alphanum.html).
>>>
>>> /Henrik
>>>
>>> ______________________________________________
>>> R-devel at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>>
>>
>



[Rd] "Human-style" sort() of alphanum strings?
Henrik Bengtsson