How can I order this list on mathematica?
Clash 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
matrix sorting
New contributor
add a comment |Â
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
matrix sorting
New contributor
3
TryMatrix[[All, Ordering[First[Matrix]]]]
.
â J. M. is computer-lessâ¦
38 mins ago
add a comment |Â
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
matrix sorting
New contributor
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
matrix sorting
New contributor
New contributor
edited 7 mins ago
bbgodfrey
43.1k857104
43.1k857104
New contributor
asked 47 mins ago
Heberley Tobón Maya
111
111
New contributor
New contributor
3
TryMatrix[[All, Ordering[First[Matrix]]]]
.
â J. M. is computer-lessâ¦
38 mins ago
add a comment |Â
3
TryMatrix[[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
add a comment |Â
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
add a comment |Â
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]] &]]
Perhaps, you meantMatrix
instead ofmyMatrix
.
â 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
add a comment |Â
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
add a comment |Â
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
add a comment |Â
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
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
answered 31 mins ago
kglr
166k8188388
166k8188388
add a comment |Â
add a comment |Â
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]] &]]
Perhaps, you meantMatrix
instead ofmyMatrix
.
â 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
add a comment |Â
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]] &]]
Perhaps, you meantMatrix
instead ofmyMatrix
.
â 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
add a comment |Â
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]] &]]
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]] &]]
edited 5 mins ago
answered 39 mins ago
David G. Stork
21.8k21747
21.8k21747
Perhaps, you meantMatrix
instead ofmyMatrix
.
â 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
add a comment |Â
Perhaps, you meantMatrix
instead ofmyMatrix
.
â 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
add a comment |Â
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.
Heberley Tobón Maya is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
3
Try
Matrix[[All, Ordering[First[Matrix]]]]
.â J. M. is computer-lessâ¦
38 mins ago