How can I order this list on mathematica?

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











up vote
2
down vote

favorite












This is my list



Matrix = 1, -2, 3, -4, a, b, f, e, a, b, f, e


I want to order the columns in ascending order depending on the values on the first row. I Expect something like



-4, -2, 1, 3, f, e, f, e, a, b, a, b


I've tried the Sort function, but it just returns the initial value










share|improve this question









New contributor




Heberley Tobón Maya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 3




    Try Matrix[[All, Ordering[First[Matrix]]]].
    – J. M. is computer-less♦
    38 mins ago















up vote
2
down vote

favorite












This is my list



Matrix = 1, -2, 3, -4, a, b, f, e, a, b, f, e


I want to order the columns in ascending order depending on the values on the first row. I Expect something like



-4, -2, 1, 3, f, e, f, e, a, b, a, b


I've tried the Sort function, but it just returns the initial value










share|improve this question









New contributor




Heberley Tobón Maya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 3




    Try Matrix[[All, Ordering[First[Matrix]]]].
    – J. M. is computer-less♦
    38 mins ago













up vote
2
down vote

favorite









up vote
2
down vote

favorite











This is my list



Matrix = 1, -2, 3, -4, a, b, f, e, a, b, f, e


I want to order the columns in ascending order depending on the values on the first row. I Expect something like



-4, -2, 1, 3, f, e, f, e, a, b, a, b


I've tried the Sort function, but it just returns the initial value










share|improve this question









New contributor




Heberley Tobón Maya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











This is my list



Matrix = 1, -2, 3, -4, a, b, f, e, a, b, f, e


I want to order the columns in ascending order depending on the values on the first row. I Expect something like



-4, -2, 1, 3, f, e, f, e, a, b, a, b


I've tried the Sort function, but it just returns the initial value







matrix sorting






share|improve this question









New contributor




Heberley Tobón Maya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Heberley Tobón Maya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 7 mins ago









bbgodfrey

43.1k857104




43.1k857104






New contributor




Heberley Tobón Maya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 47 mins ago









Heberley Tobón Maya

111




111




New contributor




Heberley Tobón Maya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Heberley Tobón Maya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Heberley Tobón Maya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 3




    Try Matrix[[All, Ordering[First[Matrix]]]].
    – J. M. is computer-less♦
    38 mins ago













  • 3




    Try Matrix[[All, Ordering[First[Matrix]]]].
    – J. M. is computer-less♦
    38 mins ago








3




3




Try Matrix[[All, Ordering[First[Matrix]]]].
– J. M. is computer-less♦
38 mins ago





Try Matrix[[All, Ordering[First[Matrix]]]].
– J. M. is computer-less♦
38 mins ago











2 Answers
2






active

oldest

votes

















up vote
3
down vote













Transpose[SortBy[Transpose[Matrix], First]]



-4, -2, 1, 3, f, e, f, e, a, b, a, b




Transpose[Transpose[#][[Ordering @ First @ #]]] &@ Matrix



-4, -2, 1, 3, f, e, f, e, a, b, a, b







share|improve this answer



























    up vote
    1
    down vote













    Renaming Matrix to myMatrix (so as to avoid starting a variable name with an upper-case letter):



    Transpose[
    SortBy[Table[myMatrix[[1, i]], myMatrix[[2, i]],
    i, 4], #[[1]] &]]





    share|improve this answer






















    • Perhaps, you meant Matrix instead of myMatrix.
      – bbgodfrey
      10 mins ago










    • Yes... in my personal code I changed the name because we must never use an upper-case letter to start the name of a variable, lest it conflict with internal definitions. Thanks. Solution amended.
      – David G. Stork
      6 mins ago










    Your Answer




    StackExchange.ifUsing("editor", function ()
    return StackExchange.using("mathjaxEditing", function ()
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    );
    );
    , "mathjax-editing");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "387"
    ;
    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
    );



    );






    Heberley Tobón Maya is a new contributor. Be nice, and check out our Code of Conduct.









     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f184118%2fhow-can-i-order-this-list-on-mathematica%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    3
    down vote













    Transpose[SortBy[Transpose[Matrix], First]]



    -4, -2, 1, 3, f, e, f, e, a, b, a, b




    Transpose[Transpose[#][[Ordering @ First @ #]]] &@ Matrix



    -4, -2, 1, 3, f, e, f, e, a, b, a, b







    share|improve this answer
























      up vote
      3
      down vote













      Transpose[SortBy[Transpose[Matrix], First]]



      -4, -2, 1, 3, f, e, f, e, a, b, a, b




      Transpose[Transpose[#][[Ordering @ First @ #]]] &@ Matrix



      -4, -2, 1, 3, f, e, f, e, a, b, a, b







      share|improve this answer






















        up vote
        3
        down vote










        up vote
        3
        down vote









        Transpose[SortBy[Transpose[Matrix], First]]



        -4, -2, 1, 3, f, e, f, e, a, b, a, b




        Transpose[Transpose[#][[Ordering @ First @ #]]] &@ Matrix



        -4, -2, 1, 3, f, e, f, e, a, b, a, b







        share|improve this answer












        Transpose[SortBy[Transpose[Matrix], First]]



        -4, -2, 1, 3, f, e, f, e, a, b, a, b




        Transpose[Transpose[#][[Ordering @ First @ #]]] &@ Matrix



        -4, -2, 1, 3, f, e, f, e, a, b, a, b








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 31 mins ago









        kglr

        166k8188388




        166k8188388




















            up vote
            1
            down vote













            Renaming Matrix to myMatrix (so as to avoid starting a variable name with an upper-case letter):



            Transpose[
            SortBy[Table[myMatrix[[1, i]], myMatrix[[2, i]],
            i, 4], #[[1]] &]]





            share|improve this answer






















            • Perhaps, you meant Matrix instead of myMatrix.
              – bbgodfrey
              10 mins ago










            • Yes... in my personal code I changed the name because we must never use an upper-case letter to start the name of a variable, lest it conflict with internal definitions. Thanks. Solution amended.
              – David G. Stork
              6 mins ago














            up vote
            1
            down vote













            Renaming Matrix to myMatrix (so as to avoid starting a variable name with an upper-case letter):



            Transpose[
            SortBy[Table[myMatrix[[1, i]], myMatrix[[2, i]],
            i, 4], #[[1]] &]]





            share|improve this answer






















            • Perhaps, you meant Matrix instead of myMatrix.
              – bbgodfrey
              10 mins ago










            • Yes... in my personal code I changed the name because we must never use an upper-case letter to start the name of a variable, lest it conflict with internal definitions. Thanks. Solution amended.
              – David G. Stork
              6 mins ago












            up vote
            1
            down vote










            up vote
            1
            down vote









            Renaming Matrix to myMatrix (so as to avoid starting a variable name with an upper-case letter):



            Transpose[
            SortBy[Table[myMatrix[[1, i]], myMatrix[[2, i]],
            i, 4], #[[1]] &]]





            share|improve this answer














            Renaming Matrix to myMatrix (so as to avoid starting a variable name with an upper-case letter):



            Transpose[
            SortBy[Table[myMatrix[[1, i]], myMatrix[[2, i]],
            i, 4], #[[1]] &]]






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 5 mins ago

























            answered 39 mins ago









            David G. Stork

            21.8k21747




            21.8k21747











            • Perhaps, you meant Matrix instead of myMatrix.
              – bbgodfrey
              10 mins ago










            • Yes... in my personal code I changed the name because we must never use an upper-case letter to start the name of a variable, lest it conflict with internal definitions. Thanks. Solution amended.
              – David G. Stork
              6 mins ago
















            • Perhaps, you meant Matrix instead of myMatrix.
              – bbgodfrey
              10 mins ago










            • Yes... in my personal code I changed the name because we must never use an upper-case letter to start the name of a variable, lest it conflict with internal definitions. Thanks. Solution amended.
              – David G. Stork
              6 mins ago















            Perhaps, you meant Matrix instead of myMatrix.
            – bbgodfrey
            10 mins ago




            Perhaps, you meant Matrix instead of myMatrix.
            – bbgodfrey
            10 mins ago












            Yes... in my personal code I changed the name because we must never use an upper-case letter to start the name of a variable, lest it conflict with internal definitions. Thanks. Solution amended.
            – David G. Stork
            6 mins ago




            Yes... in my personal code I changed the name because we must never use an upper-case letter to start the name of a variable, lest it conflict with internal definitions. Thanks. Solution amended.
            – David G. Stork
            6 mins ago










            Heberley Tobón Maya is a new contributor. Be nice, and check out our Code of Conduct.









             

            draft saved


            draft discarded


















            Heberley Tobón Maya is a new contributor. Be nice, and check out our Code of Conduct.












            Heberley Tobón Maya is a new contributor. Be nice, and check out our Code of Conduct.











            Heberley Tobón Maya is a new contributor. Be nice, and check out our Code of Conduct.













             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f184118%2fhow-can-i-order-this-list-on-mathematica%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?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay