Sort differences

A Linux-using friend asked for help creating a script to sort files numerically on the 2nd comma-delimited field of a set of Ascii files. So, at home on my Mac, I consulted the man page and came up with the following, which works just fine:
sort -t, -k2n filename
However, it doesn't work on Linux, where it doesn't complain about anything, it just doesn't sort correctly. The Linux man pages seem to support this set of options. (Yeah, I know, it's not Linux, but the sort program that's at issue. And this is a Mac forum, not a Linux one.) The Mac sort is from GNU while the two Linux (Ubuntu and Red Hat) sorts are from FSF.
Could this simply be chalked up to an FSF sort bug?
If anyone cares to play with this, here is some test data.
xyz,5,abc
asdfa,3,asdfads
werttwrwrtwtr,2,43234545
a,4,z
qqqqq,10,zzzz

Hi Ken,
Your post is quite interesting. The command line syntax of the sort command is quite complilcated and always a headache to me. The following are what I have found:
(1) It is always safer to specify the sort key as -k2,2 (not -k2). If you specfy just -k2 then it means "from the 2nd field to the end of the line". So
sort -t, -k2,2n filename
should give the desired result (both in Linux and MacOSX).
(2) GNU and FSF are "virtually" the same thing (FSF supports GNU project). The sort command in Tiger is from GNU but quite old
Tiger$ sort --version
sort - GNU textutils 1.14
The ones in (recent) Linux distros are also from GNU but much newer (textutils 2.x or coreutils, which is the successor of textutils).
(3) Older sort commands (like the one in Tiger) do not consider comma "," as part of a number. But newer ones can recognize the "thousands separator", with locale support. "Locale supoort" means that the values of the "decimal point" and the "thousands separator" depend on the locale (for example, French locale uses different values than many other locales.) If no locale is specified then it behaves as the older version, so
Linux$ LC_NUMERIC=C sort -t, -k2n filename
would work (but better to use -k2,2n).
(4) The newer sort also has the -g option. This can handle scientific notation like "6.022e-23", but slower than -n and can be affected by the rounding error. It seems -g does not support the "thousands separator".
(5) Sometimes (not always) "info sort" gives more recent (or detailed) description of the command than "man sort".

Similar Messages

  • Sorting differences between Oracle and SQL Server

    Hello All,
    This question is related to both Oracle and SQL Server
    I have a requirement where I want to compare 2 tables line by line. One table is in Oracle and other table is in SQL Server
    And suppose that both of the tables don't have a primary key. Now when I sort the records using order by clause for a column then -
    Rows having null values in that column of Oracle are placed at the bottom.
    Where as Rows having null values in the same column of SQL Server are placed right at the top.
    How can I make either of them to behave like other.
    My sole aim is to have same order of occurrence of rows in both Oracle and SQL Server tables so that I can compare them line by line.

    For example :
    select * from emp order by comm;
    So all null value in comm column are at the end.
    Now if you wish to get them on the top of select output then :
    SELECT EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,NVL(COMM,0) COMM,DEPTNO FROM EMP ORDER BY COMM;
    Means i am using NVL (oracle function) function. If comm column is having null value it will converted to zero value at the time of exectuion of select query.
    So, now comm column is having zero value in select output and SQL Server is having nulls at the top. I do'nt know who to make nulls to zero in SQL Server. So issue solved.
    HTH
    Girish Sharma

  • Differences in sort order between iTunes and iPod

    Can someone explain how the sort order of artists / albums works? It seems that it is different between iTunes and the iPod. In iTunes (7.3.1) I can enter data in the fields for Artist, Album Artist, Sort Artist and Sort Album Artist. When I get the tracks to appear in the order I want in iTunes, it doesn’t seem to transfer across to my iPod. I know there are some differences in how the sort order works in both, but how is it different?
    John.
    Dell 5150   Windows XP  

    ou must have an older iPod.
    I believe the new sort order only works on the new iPods (Nano and Video)

  • Differences between standard structured sorted hashed internal tables.

    can any one elobrate the differences among them with simple examples.
    why hashed table serch is faster...what happens if list is not sorted...explain the scenarios best suitable ..when we go for what kinda tables...

    <a href="http://www.sap-img.com/abap/what-are-different-types-of-internal-tables-and-their-usage.htm">refer this link for details</a>
    <a href="http://www.geekinterview.com/question_details/1498">also refer this</a>
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb366d358411d1829f0000e829fbfe/content.htm">also this- SAP Help</a>
    regards,
    srinivas

  • Would these 2 different Sorting methods makes a difference in performance?

    Hi I'm using vs2012.
    My page is loading up slow.  I was wondering if there is a performance difference to these 2 Sort methods?  The sorted collection is then bind to a gridview control in my web page.
    List<UserPrincipal> users = new List<UserPrincipal>();
    users.OrderBy(x => x.SamAccountName).ToList(); 
    and 
    users.Sort(delegate(UserPrincipal a, UserPrincipal b) { return string.Compare(a.SamAccountName, b.SamAccountName); });
    Thank you.
    Thank you

    First, thanks everyone for your help and input.
    I checked the vm that I use as a web server.  In the Windows task manager, the cpu shows 1% usage and 8GB of ram only 1.6 GB are used.  
    I step through program many times but never notice any sticky spot so I did it again this time looking out for possible performance issue.  It turns out that the Sorting loc steps right through with no delay.  Setting a few break points to measure
    where the performance problem could be at my local development PC finds NADA!  First break points set at the Page_Load event and then more break points at some other major code block and they all just step right through with no problem.  
    It does take almost 5 seconds for VS to hit the first BP, at Page_Load event.  Is this normal?  Any other tool that I can use to find out what's causing the slow page load from the web server?
    Thank you.
    Thank you

  • What is the difference between standard,sorted and hash table

    <b>can anyone say what is the difference between standard,sorted and hash tabl</b>

    Hi,
    Standard Tables:
    Standard tables have a linear index. You can access them using either the index or the key. If you use the key, the response time is in linear relationship to the number of table entries. The key of a standard table is always non-unique, and you may not include any specification for the uniqueness in the table definition.
    This table type is particularly appropriate if you want to address individual table entries using the index. This is the quickest way to access table entries. To fill a standard table, append lines using the (APPEND) statement. You should read, modify and delete lines by referring to the index (INDEX option with the relevant ABAP command). The response time for accessing a standard table is in linear relation to the number of table entries. If you need to use key access, standard tables are appropriate if you can fill and process the table in separate steps. For example, you can fill a standard table by appending records and then sort it. If you then use key access with the binary search option (BINARY), the response time is in logarithmic relation to
    the number of table entries.
    Sorted Tables:
    Sorted tables are always saved correctly sorted by key. They also have a linear key, and, like standard tables, you can access them using either the table index or the key. When you use the key, the response time is in logarithmic relationship to the number of table entries, since the system uses a binary search. The key of a sorted table can be either unique, or non-unique, and you must specify either UNIQUE or NON-UNIQUE in the table definition. Standard tables and sorted tables both belong to the generic group index tables.
    This table type is particularly suitable if you want the table to be sorted while you are still adding entries to it. You fill the table using the (INSERT) statement, according to the sort sequence defined in the table key. Table entries that do not fit are recognised before they are inserted. The response time for access using the key is in logarithmic relation to the number of
    table entries, since the system automatically uses a binary search. Sorted tables are appropriate for partially sequential processing in a LOOP, as long as the WHERE condition contains the beginning of the table key.
    Hashed Tables:
    Hashes tables have no internal linear index. You can only access hashed tables by specifying the key. The response time is constant, regardless of the number of table entries, since the search uses a hash algorithm. The key of a hashed table must be unique, and you must specify UNIQUE in the table definition.
    This table type is particularly suitable if you want mainly to use key access for table entries. You cannot access hashed tables using the index. When you use key access, the response time remains constant, regardless of the number of table entries. As with database tables, the key of a hashed table is always unique. Hashed tables are therefore a useful way of constructing and
    using internal tables that are similar to database tables.
    Regards,
    Ferry Lianto

  • What is the difference between "Sort By", "Arrange By", and "Clean Up By"?

    What is the difference between "Sort By", "Arrange By", and "Clean Up By"? They are different from SL.

    A MAC address is a unique identification consisting of letters and numbers in a form that looks like this:
    xx:xx:xx:xx:xx:xx
    Every network device has a MAC address, which can be found on a label on the bottom or back of the device. Apple calls this the Ethernet ID.
    A DHCP Client ID is an optional name that you can assign to a device. For example, on your Mac....
    Open System Preferences (gear icon on the dock)
    Open Network
    Click on Ethernet
    Click Advanced at the lower right
    You may be able to edit the DHCP Client  ID here....for example.....you could enter MJ500's MacBook in the space provided. That would be the Client ID of your Mac.

  • Actual difference between a standard , sorted and hashed atble

    hi ,
    1. what is the actual difference between a
       standard,sorted and hashed table ? and
    2. where and when these are actually used and applied ?
       provide explanation with an example ....

    hi
    good
    Standard Internal Tables
    Standard tables have a linear index. You can access them using either the index or the key. If you use the key, the response time is in linear relationship to the number of table entries. The key of a standard table is always non-unique, and you may not include any specification for the uniqueness in the table definition.
    This table type is particularly appropriate if you want to address individual table entries using the index. This is the quickest way to access table entries. To fill a standard table, append lines using the (APPEND) statement. You should read, modify and delete lines by referring to the index (INDEX option with the relevant ABAP command).  The response time for accessing a standard table is in linear relation to the number of table entries. If you need to use key access, standard tables are appropriate if you can fill and process the table in separate steps. For example, you can fill a standard table by appending records and then sort it. If you then use key access with the binary search option (BINARY), the response time is in logarithmic relation to
    the number of table entries.
    Sorted Internal Tables
    Sorted tables are always saved correctly sorted by key. They also have a linear key, and, like standard tables, you can access them using either the table index or the key. When you use the key, the response time is in logarithmic relationship to the number of table entries, since the system uses a binary search. The key of a sorted table can be either unique, or non-unique, and you must specify either UNIQUE or NON-UNIQUE in the table definition.  Standard tables and sorted tables both belong to the generic group index tables.
    This table type is particularly suitable if you want the table to be sorted while you are still adding entries to it. You fill the table using the (INSERT) statement, according to the sort sequence defined in the table key. Table entries that do not fit are recognised before they are inserted. The response time for access using the key is in logarithmic relation to the number of
    table entries, since the system automatically uses a binary search. Sorted tables are appropriate for partially sequential processing in a LOOP, as long as the WHERE condition contains the beginning of the table key.
    Hashed Internal Tables
    Hashes tables have no internal linear index. You can only access hashed tables by specifying the key. The response time is constant, regardless of the number of table entries, since the search uses a hash algorithm. The key of a hashed table must be unique, and you must specify UNIQUE in the table definition.
    This table type is particularly suitable if you want mainly to use key access for table entries. You cannot access hashed tables using the index. When you use key access, the response time remains constant, regardless of the number of table entries. As with database tables, the key of a hashed table is always unique. Hashed tables are therefore a useful way of constructing and
    using internal tables that are similar to database tables.
    THANKS
    MRUTYUN

  • Difference between ordered by and sorted by?

    hi,
    Can any1 tell me wats the actual difference between ordered by and sorted by???

    Generally speaking, when talking math, one talks about an "ordering" in some set of values. Usually one doesn't actually place them in order; the order is already there, implicit in the values. When talking computer science, one talks about "sorting" because the values may be in a sequence which violates the desired order, and you have to sort the sequence to match the order. "Sorting" isn't as relevant in math because there is no sense of the items being out of sequence when the order is established.
    So "order" describes the ideal (which mathematicians care about).
    "Sort" describes the practical, the activity needed to make the real match the ideal (which computer sciences care about).
    That's my intuitive feeling on it, anyway.

  • Differences between Standard , sorted and hashed internal tables

    Can any body please tell me what are the main Differences between
    1) <b>Standard internal table</b>
    2) <b>Hashed internal table</b>
    3) <b>Sorted internal table</b>
    Please give me a clear idea about these Three.
    Thanks
    Prabhudutta<b></b>

    Hi,
    <b>Standard Internal Tables</b>
    Standard tables have a linear index. You can access them using either the index or the key. If you use the key, the response time is in linear relationship to the number of table entries. The key of a standard table is always non-unique, and you may not include any specification for the uniqueness in the table definition.
    This table type is particularly appropriate if you want to address individual table entries using the index. This is the quickest way to access table entries. To fill a standard table, append lines using the (APPEND) statement. You should read, modify and delete lines by referring to the index (INDEX option with the relevant ABAP command).  The response time for accessing a standard table is in linear relation to the number of table entries. If you need to use key access, standard tables are appropriate if you can fill and process the table in separate steps. For example, you can fill a standard table by appending records and then sort it. If you then use key access with the binary search option (BINARY), the response time is in logarithmic relation to
    the number of table entries.
    <b>Sorted Internal Tables</b>
    Sorted tables are always saved correctly sorted by key. They also have a linear key, and, like standard tables, you can access them using either the table index or the key. When you use the key, the response time is in logarithmic relationship to the number of table entries, since the system uses a binary search. The key of a sorted table can be either unique, or non-unique, and you must specify either UNIQUE or NON-UNIQUE in the table definition.  Standard tables and sorted tables both belong to the generic group index tables.
    This table type is particularly suitable if you want the table to be sorted while you are still adding entries to it. You fill the table using the (INSERT) statement, according to the sort sequence defined in the table key. Table entries that do not fit are recognised before they are inserted. The response time for access using the key is in logarithmic relation to the number of
    table entries, since the system automatically uses a binary search. Sorted tables are appropriate for partially sequential processing in a LOOP, as long as the WHERE condition contains the beginning of the table key.
    <b>Hashed Internal Tables</b>
    Hashes tables have no internal linear index. You can only access hashed tables by specifying the key. The response time is constant, regardless of the number of table entries, since the search uses a hash algorithm. The key of a hashed table must be unique, and you must specify UNIQUE in the table definition.
    This table type is particularly suitable if you want mainly to use key access for table entries. You cannot access hashed tables using the index. When you use key access, the response time remains constant, regardless of the number of table entries. As with database tables, the key of a hashed table is always unique. Hashed tables are therefore a useful way of constructing and
    using internal tables that are similar to database tables.
    Regards
    Sudheer

  • Upgrade -- Sort sequence difference in ECC 6.0 and 4.7

    Hello friends,
    We are in an upgrade project where the upgrade is from 4.7 version to ECC 6.0 version.
    We are facing few problems on sort when testing our Z developments.
    Suppose the internal table in the program has fields A, B and C.
    We are using the sort statement --> sort itab by A.
    In 4.7, the sort statement sorts the internal table first by A and there is no specific sequence followed for B or C.
    Whereas in ECC 6.0, the sort happens by A followed by B and C.
    So, the final result is, for the user, the output appears different, although the data is the same.
    Please let me know how can we make the output in ECC 6.0 appear as in 4.7.
    Thanks & Regards
    Swapnil

    Hello Swapnil,
    Check for the SORT keyword in transaction abapdocu. You may see the changes made to the functionality in the newer versions.
    Thank You,
    Sai

  • Difference Between Begin of itab occurs 0 and declaring Std,sort,Hash tab

    Can anyone explian the reason abt the begin of itab occurs 0
    Before 3.0 they use to define INternal tabls in this way.....
    Now, we are using Standard , Sorted, hashed tables...
    Can any body explain me abt the change that has occured and why it has occured?
    HAve a great day!
    Regards,
    Krishna Chaitanya
    Edited by: Alvaro Tejada Galindo on Apr 14, 2008 3:20 PM

    Hello,
    Thanks for your resposne!
    I got the answer in SAP HELP....
    Before 3.0 Internal Tables all had Header Lines and a Flat-structured line type. There were no independent Table types
    You could only create a Table Object using the occurs addition in data structures...
    But, now we can create a Table Type after 4.0 with which we can use itables more efficiently..as Data objects occupy memory and for Table type their will be no memory allocated.
    This is reason, I found.....
    Have a great day!
    Regards,
    Krishna Chaitanya

  • HT1414 new iphone 3, had trouble setting up, took about 5 hours and call to Texas, finally sorted by following morning. Now  after 5 weeks No Service suddenly appears and no closing down etc makes any difference. Connect to itunes and SIM not recognised!

    what do you do when new iphone 3 will not accept SIM card which it has been doing since I bought it 6 weeks ago but now suddenly No Service and will not recognise SIM. Had this trouble on initial start up, took a 3 hour conversation with Apple USA to get it going. Can't connect to itunes because it won't recognise the SIM. Cannot remember what we did to get it going last time as it took so long and we did so many different things. Any suggestions other than put it in the bin!

    First, though the phone is "new" to you, it really is a 5 year old piece of equipment.  Ancient by current standards.
    Have you obtained a replacement SIM from your carrier? 

  • The difference between Telepresence Content Server and MSE 3500

    Good day! Could someone explain me what's the difference between Telepresence Content Server and MSE 3500? Why do I need to obtain two these devices for sorting out my tasks? I want to understand gist of the first and the second devices.

    In addition to what Jonathan posted above, here is a Capture Transform Share Solution Guide that goes over a little bit of what the TCS and MXE are and some possible deployment scenarios.
    In short, TCS is used to record video conferences or lectures that can be streamed on demand or live using various streaming or distribution methods.  One such distribution method is using the MXE 3500 to ingest the recordings from TCS and convert them to different media types and add in-video content such as logos etc.  However, from the MXE, you can't send the video back to the TCS for viewing, you'd need to send that off to another viewing portal such as Show and Share.

  • What is difference between Documanage and Documaker?

    Guys..
    We are new to ECM, one of our customer is using both Documaker(Distributed) and Documanage for their vendor document management. So just I would like to know what would be the reason to use both? Instead can they use only documaker?
    Thanks in advance.
    Edited by: Ram on Nov 4, 2011 1:37 AM

    There is a huge level of difference - Documaker generates documents and print files based on a rules engine and document templates. Documanage does not generate any sort of documents - it is a document repository. Documaker incorporates a rudimentary transaction archive facility but it does not archive print streams or PDF documents, or anything else for that matter. This is where Documanage is quite usable.
    You would probably do well to investigate some of the documentation as your question is really too broad to answer with any appreciable level of detail.
    Documanage: http://download.oracle.com/docs/cd/E14904_01/E14904-01_index.html
    Documaker: http://download.oracle.com/docs/cd/E17552_01/e17552_01_index.html
    Edited by: Andy Little on Nov 4, 2011 11:09 AM

Maybe you are looking for

  • How to use my dv camera on my mackbook(Late 2008)

    hi... my name is Thiago.. and i have an sony digital video camera that i used in my old mackbook with a firewire 6 pin cable.. but now i cant use my camera because there is no firewire 6 pin connector in the macbook(late 2008) my camera have a firewi

  • How many monitors can you use on a new imac with GEForce 780m?

    My husband bought a new 27" iMac with the optional GEForce 780m with 4 gig of video ram. He wants to know how many monitors he can run simultaneously, and at what resolutions. He would obviously be using the Thunderbolt ports to do this. I thought th

  • Library of congress jp2 files not opening in photoshop

    Am I missing something?  I am using Adobe Photoshop CC (2014).. but when I attempt to open a .jp2 file (JPEG 2000) downloaded from the LoC, I get an error in Photoshop saying "Could not complete your request because the file-format module cannot pars

  • Unable to start apache in oracle apps r12

    hi, we are unable to start Apache in one of our test instance. in Error log.. /home/mnt/ebs/PRJ/app/inst/apps/PRJ_rempapp/ora/10.1.3/Apache/Apache/bin/apachectl startssl: execing httpd Error: Failed to open the wallet [Hint: incorrect path, incorrect

  • Transporting authorization object (RSSM)

    Hi, I am having problem transporting my BW Custom authorization object over to the Quality system. I have successfully transported the table contents RSSTOBJDIR to the Quality system. However, when I search for the authorization object in RSSM in Qua