How to get the same sorting result for this pattern

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












When I use sort -n -k 2 -r on a text like this one:



último 12
últimos 5
única 27
único 227
úteis 2
útil 1


I get the expected result as you can see:



único 227
única 27
último 12
últimos 5
úteis 2
útil 1


Do you guys know if it is possible to get this working for the second column of a pattern like this ??



(zelar,12)
(zero,1)
(zes,1)
(zeze,12)
(ziza,2)
(zo,1)
(zona,6)






share|improve this question
















  • 2




    Is it sufficient to set the field separator to , i.e. sort -t, -n -k 2 -r?
    – steeldriver
    Nov 5 '17 at 0:39










  • @steeldriver thank you, it worked like a charm :-)
    – Gabriel
    Nov 5 '17 at 0:53














up vote
2
down vote

favorite












When I use sort -n -k 2 -r on a text like this one:



último 12
últimos 5
única 27
único 227
úteis 2
útil 1


I get the expected result as you can see:



único 227
única 27
último 12
últimos 5
úteis 2
útil 1


Do you guys know if it is possible to get this working for the second column of a pattern like this ??



(zelar,12)
(zero,1)
(zes,1)
(zeze,12)
(ziza,2)
(zo,1)
(zona,6)






share|improve this question
















  • 2




    Is it sufficient to set the field separator to , i.e. sort -t, -n -k 2 -r?
    – steeldriver
    Nov 5 '17 at 0:39










  • @steeldriver thank you, it worked like a charm :-)
    – Gabriel
    Nov 5 '17 at 0:53












up vote
2
down vote

favorite









up vote
2
down vote

favorite











When I use sort -n -k 2 -r on a text like this one:



último 12
últimos 5
única 27
único 227
úteis 2
útil 1


I get the expected result as you can see:



único 227
única 27
último 12
últimos 5
úteis 2
útil 1


Do you guys know if it is possible to get this working for the second column of a pattern like this ??



(zelar,12)
(zero,1)
(zes,1)
(zeze,12)
(ziza,2)
(zo,1)
(zona,6)






share|improve this question












When I use sort -n -k 2 -r on a text like this one:



último 12
últimos 5
única 27
único 227
úteis 2
útil 1


I get the expected result as you can see:



único 227
única 27
último 12
últimos 5
úteis 2
útil 1


Do you guys know if it is possible to get this working for the second column of a pattern like this ??



(zelar,12)
(zero,1)
(zes,1)
(zeze,12)
(ziza,2)
(zo,1)
(zona,6)








share|improve this question











share|improve this question




share|improve this question










asked Nov 5 '17 at 0:23









Gabriel

133




133







  • 2




    Is it sufficient to set the field separator to , i.e. sort -t, -n -k 2 -r?
    – steeldriver
    Nov 5 '17 at 0:39










  • @steeldriver thank you, it worked like a charm :-)
    – Gabriel
    Nov 5 '17 at 0:53












  • 2




    Is it sufficient to set the field separator to , i.e. sort -t, -n -k 2 -r?
    – steeldriver
    Nov 5 '17 at 0:39










  • @steeldriver thank you, it worked like a charm :-)
    – Gabriel
    Nov 5 '17 at 0:53







2




2




Is it sufficient to set the field separator to , i.e. sort -t, -n -k 2 -r?
– steeldriver
Nov 5 '17 at 0:39




Is it sufficient to set the field separator to , i.e. sort -t, -n -k 2 -r?
– steeldriver
Nov 5 '17 at 0:39












@steeldriver thank you, it worked like a charm :-)
– Gabriel
Nov 5 '17 at 0:53




@steeldriver thank you, it worked like a charm :-)
– Gabriel
Nov 5 '17 at 0:53










1 Answer
1






active

oldest

votes

















up vote
3
down vote



accepted










Add -t, to your sort command to make it use comma as the field separator. 
(You can add it to the command anywhere except between the -k and the 2.) 
Note that this will not grant any special significance to the parentheses,
so, if you have some rows with parentheses and some without,
then lines where the number in the second column are equal will sort like this:



z,…
a,…
9,…
︙
2,…
10,…
1,…
(z…),…
(a…),…





share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f402571%2fhow-to-get-the-same-sorting-result-for-this-pattern%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    3
    down vote



    accepted










    Add -t, to your sort command to make it use comma as the field separator. 
    (You can add it to the command anywhere except between the -k and the 2.) 
    Note that this will not grant any special significance to the parentheses,
    so, if you have some rows with parentheses and some without,
    then lines where the number in the second column are equal will sort like this:



    z,…
    a,…
    9,…
    ︙
    2,…
    10,…
    1,…
    (z…),…
    (a…),…





    share|improve this answer
























      up vote
      3
      down vote



      accepted










      Add -t, to your sort command to make it use comma as the field separator. 
      (You can add it to the command anywhere except between the -k and the 2.) 
      Note that this will not grant any special significance to the parentheses,
      so, if you have some rows with parentheses and some without,
      then lines where the number in the second column are equal will sort like this:



      z,…
      a,…
      9,…
      ︙
      2,…
      10,…
      1,…
      (z…),…
      (a…),…





      share|improve this answer






















        up vote
        3
        down vote



        accepted







        up vote
        3
        down vote



        accepted






        Add -t, to your sort command to make it use comma as the field separator. 
        (You can add it to the command anywhere except between the -k and the 2.) 
        Note that this will not grant any special significance to the parentheses,
        so, if you have some rows with parentheses and some without,
        then lines where the number in the second column are equal will sort like this:



        z,…
        a,…
        9,…
        ︙
        2,…
        10,…
        1,…
        (z…),…
        (a…),…





        share|improve this answer












        Add -t, to your sort command to make it use comma as the field separator. 
        (You can add it to the command anywhere except between the -k and the 2.) 
        Note that this will not grant any special significance to the parentheses,
        so, if you have some rows with parentheses and some without,
        then lines where the number in the second column are equal will sort like this:



        z,…
        a,…
        9,…
        ︙
        2,…
        10,…
        1,…
        (z…),…
        (a…),…






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 5 '17 at 0:55









        G-Man

        11.6k82657




        11.6k82657



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f402571%2fhow-to-get-the-same-sorting-result-for-this-pattern%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?