[Cialug] Alphabetical Sort

Dave Weis djweis at sjdjweis.com
Wed Dec 11 18:19:53 CST 2013


If it's in a database you'll need to sort by substrings delimited by periods coalesced into numbers. 

-------- Original message --------
From: Scott Yates <Scott at yatesframe.com> 
Date:12/11/2013  6:04 PM  (GMT-06:00) 
To: Central Iowa Linux Users Group <cialug at cialug.org> 
Subject: Re: [Cialug] Alphabetical Sort 

Maybe this will help?  Have not tried on your specific case. Sort by number

The -n option makes the program sort according to numerical value:


$ du /bin/* | sort -n
4       /bin/domainname
24      /bin/ls
102     /bin/sh
304     /bin/csh



On Wed, Dec 11, 2013 at 5:35 PM, Patrick Mcgillan <
patrick.mcgillan at gmail.com> wrote:

> I have this problem where a SQl field contains characters like this in
> different records.
>
> 1.4.1
> 1.4.10
> 1.4.2
> 1.5.1
> 1.5.10
> 1.5.11
> 1.5.12
> 1.5.2
> 1.5.3
> Trouble is, 1.4.2 should sort out before 1.4.10, but because it is a
> character field it doesn't. Now that makes perfectly good sense to me, but
> not the customer. I can't sort on ID as the entries are randomly done. I
> sense that this problem has been solved before, but can't put my finger on
> it.
>
> Can anybody point me in the proper direction.
>
> Patrick
> _______________________________________________
> Cialug mailing list
> Cialug at cialug.org
> http://cialug.org/mailman/listinfo/cialug
>
_______________________________________________
Cialug mailing list
Cialug at cialug.org
http://cialug.org/mailman/listinfo/cialug


More information about the Cialug mailing list