LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 07-30-2010, 01:05 AM   #1
BerzinTehvs
Member
 
Registered: Mar 2005
Location: Latvia
Distribution: Slackware
Posts: 47

Rep: Reputation: 15
awk's asort sort order according to locale


Hi!

How could it be possible to make awk asort function to be locale-aware?

Systems locale is set to lv_LV, but asort ignores it and sorts as if LC_COLLATE is en_US. Text to be sorted is ISO8859-13 encoded.

output of locale:

LANG=lv_LV
LC_CTYPE="lv_LV"
LC_NUMERIC="lv_LV"
LC_TIME="lv_LV"
LC_COLLATE="lv_LV"
LC_MONETARY="lv_LV"
LC_MESSAGES=en_GB
LC_PAPER="lv_LV"
LC_NAME="lv_LV"
LC_ADDRESS="lv_LV"
LC_TELEPHONE="lv_LV"
LC_MEASUREMENT="lv_LV"
LC_IDENTIFICATION="lv_LV"
LC_ALL=

malfunctioning part of script:
Code:
TMPO=`echo $F4 | awk -F ", " '{RS=ORS=", "; n=split($0,arr); asort(arr); for (i = 1; i <= n; i++) print arr[i] }'`

Last edited by BerzinTehvs; 07-30-2010 at 01:06 AM.
 
Old 07-30-2010, 01:38 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,978
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
How about sample data and sample output?
 
Old 07-30-2010, 02:49 AM   #3
BerzinTehvs
Member
 
Registered: Mar 2005
Location: Latvia
Distribution: Slackware
Posts: 47

Original Poster
Rep: Reputation: 15
I'll better attach the script and the input file.

it should be used so: sinon.sh -s tabula.txt

the last line of current output looks so:
Code:
uzvinnēt:1:(darb.v.):uzvarēt, āpmakt
but it has to look so:
Code:
uzvinnēt:1:(darb.v.):āpmakt, uzvarēt
besause "ā" is the second letter in Latvian alphabet. Sorting within regular a-z works ok.

(sorry, comments in script are in Latvian)
Attached Files
File Type: txt tabula.txt (173 Bytes, 4 views)
File Type: txt sinon.sh.txt (4.0 KB, 4 views)

Last edited by BerzinTehvs; 07-30-2010 at 02:53 AM. Reason: emoticons showind up unneeded
 
Old 08-03-2010, 02:12 AM   #4
BerzinTehvs
Member
 
Registered: Mar 2005
Location: Latvia
Distribution: Slackware
Posts: 47

Original Poster
Rep: Reputation: 15
As far as it seems to me after studying of the source - gawk's asort() function is not locale-aware. At least - I did not notice any code comparable to sort's from coreutils.
 
Old 08-03-2010, 02:01 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,978
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Quote:
Originally Posted by BerzinTehvs View Post
As far as it seems to me after studying of the source - gawk's asort() function is not locale-aware. At least - I did not notice any code comparable to sort's from coreutils.
That's a real shame. Maybe you should submit a bug, or
a feature request?


Cheers,
Tink
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Sort in descending order according to a column of an array flea89 Linux - Newbie 3 03-14-2010 06:00 PM
Can I use GNU sort to sort one field in order, another in reverse? zombieite Linux - Newbie 4 04-27-2009 12:23 AM
How do I do filtering in Perl (keep sort order and sort again by another means)? RavenLX Programming 9 12-19-2008 10:12 AM
Suggestion: Let's sort them in a,b,c... order fuelinux LQ Suggestions & Feedback 8 01-20-2008 10:35 AM
Sort order in nautilus Patrick K Ubuntu 4 06-12-2007 08:53 PM


All times are GMT -5. The time now is 04:08 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration