Sponsored Content
Full Discussion: Sort function UNIX bug ???
Top Forums Shell Programming and Scripting Sort function UNIX bug ??? Post 302743417 by kykyboss on Wednesday 12th of December 2012 07:16:38 PM
Old 12-12-2012
Hammer & Screwdriver Sort function UNIX bug ???

Hello there

i have a funny behiavor of the sort fonction, i try it out on different Solaris machine and i have the same issue.
So i would like to see if there is a rationel explanation

here is some data in a file:test.txt

Code:
,Test,RSD,RSD_Asset
,Test,RSD,RSD_Credit
,Test,RSD,RSD_Liab
,Test,RSD,VA,VAFA,VAFA_Asset
,Test,RSD,VA,VAFA,VAFA_Credit
,Test,RSD,VA,VA_Liab
,Test,RSD,RSD_Mort
,Test,RSD,RSDA
,Test,RSD,RSD_Oper
,Test,RSD,VA
,Test,RSD,VA,VAFA
,Test,RSD,VA,VAFA,VAFA_Liab
,Test,RSD,VA,VA_Asset

now if i sort that file, i receive this
sort test.txt

Code:
,Test,RSD,RSDA
,Test,RSD,RSD_Asset
,Test,RSD,RSD_Credit
,Test,RSD,RSD_Liab
,Test,RSD,RSD_Mort
,Test,RSD,RSD_Oper
,Test,RSD,VA
,Test,RSD,VA,VA_Asset
,Test,RSD,VA,VAFA
,Test,RSD,VA,VAFA,VAFA_Asset
,Test,RSD,VA,VAFA,VAFA_Credit
,Test,RSD,VA,VAFA,VAFA_Liab
,Test,RSD,VA,VA_Liab

and here are a couple of strange things happening

1:
if you look the start of the file
Code:
,Test,RSD,RSDA
,Test,RSD,RSD_Asset
,Test,RSD,RSD_Credit

it seem that the charactere "_" is sorted after the alphabete (that is what i want)

2: but if you look further
how come
Code:
,Test,RSD,VA,VA_Asset

is before
Code:
,Test,RSD,VA,VAFA

and how come
Code:
,Test,RSD,VA,VA_Liab

is not next
Code:
,Test,RSD,VA,VA_Asset

I am getting crazy ????Smilie Smilie


I will like to have the following output (which make the more sence for the sorting fontion)

Code:
,Test,RSD,RSDA
,Test,RSD,RSD_Asset
,Test,RSD,RSD_Credit
,Test,RSD,RSD_Liab
,Test,RSD,RSD_Mort
,Test,RSD,RSD_Oper
,Test,RSD,VA
,Test,RSD,VA,VAFA
,Test,RSD,VA,VAFA,VAFA_Asset
,Test,RSD,VA,VAFA,VAFA_Credit
,Test,RSD,VA,VAFA,VAFA_Liab
,Test,RSD,VA,VA_Asset
,Test,RSD,VA,VA_Liab

thanks for your comments!!!
i am using
SunOS talos 5.10 Generic_147440-12 sun4u sparc SUNW,Sun-Fire-V490
 

9 More Discussions You Might Find Interesting

1. Programming

sort function

do any one knows where i can find an implementation in c for the sort function (2 Replies)
Discussion started by: dbargo
2 Replies

2. Shell Programming and Scripting

Function Bug in script - need help

My script is erroring with: testtapemgr.sh: FTP_RETURNS: not found I cannot see what I am doing wrong..when it calls that function from the Volume returns function and says taht FTP_RETURNS is not found and exits out of the script. What am I not seeing here? #### Return Volume Function ... (4 Replies)
Discussion started by: gzs553
4 Replies

3. Shell Programming and Scripting

sort function in perl

Hi, here is my perl script.This script creates an array and is sorting it using the in-built sort function in perl. #!/usr/local/bin/perl my number=6; my @num_arr=(1,2,3,4,5); my @array=(23,"$number","Hello",2.345,@num_arr); #printing the array print... (2 Replies)
Discussion started by: DILEEP410
2 Replies

4. Shell Programming and Scripting

bash-function with array acting bizarre, bug?

Hello, basically what this script is supposed to do is showing a list of hosts that is given a number, that you will be able to choose from a list. A check is made to verify that the chosen number is within the array and this is where things go bad and I don't know why, bizarre. I've spent... (5 Replies)
Discussion started by: gand
5 Replies

5. Homework & Coursework Questions

Sort function -- My First Unix Homework!

1. The problem statement, all variables and given/known data: To sort a data 2. Relevant commands, code, scripts, algorithms: The data provided is saved in dummy.txt and provided in LIBSVM format, but I think this information is redundant.. +1 1:2 2:4 4:3.2 -1 2:2.1 2:2.1 ... (4 Replies)
Discussion started by: eeweepoh
4 Replies

6. Shell Programming and Scripting

Bug in Function Call

Can anybody tell me where is the bug in this below mentioned function call. #The String Search File myString="${LOCATION}/config/stringFile.txt" # Functional Usage function usage() { if ; then echo "************************************************************" ... (5 Replies)
Discussion started by: baraghun
5 Replies

7. Programming

Tweaked getpass() function gives an untraceable bug

I have customized the getpass() as follows: char* my_getpass(const char* str) { struct termios oflags, nflags; static char passwd; /* disabling echo */ tcgetattr(fileno(stdin), &oflags); nflags = oflags; nflags.c_lflag &= ~ECHO; nflags.c_lflag |= ECHONL; ... (3 Replies)
Discussion started by: royalibrahim
3 Replies

8. What is on Your Mind?

Small bug in the Quick Editor function in postbit

Hey, There was a small bug in the Quick Editor function in postbit, but I fixed it (basically a double quote was missing from an element id): <div id="post_message_$post" class="neo-message-area">$post</div> Was <div id="post_message_$post class="neo-message-area">$post</div> Should... (1 Reply)
Discussion started by: Neo
1 Replies

9. UNIX for Beginners Questions & Answers

Inconsistent results using sort function

Could you please advise on the following: I have two space-delimited files with 9 and 10 columns, respectively, with exactly the same values in column 1. However, the order of column 1 differs between the two files, so I want to sort both files by column 1, so that I can align them and... (6 Replies)
Discussion started by: aberg
6 Replies
All times are GMT -4. The time now is 09:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy