Sorting a Numpy array by column not axis [duplicate]Sorting arrays in NumPy by columnHow do I sort a list of dictionaries by a value of the dictionary?Sort a Map<Key, Value> by valuesHow do I sort a dictionary by value?Sorting an array of JavaScript objects by propertySort array of objects by string property valueHow to sort a dataframe by multiple column(s)How to Sort Multi-dimensional Array by Value?Fastest sort of fixed length 6 int arrayNumpy array dimensionsSwift Beta performance: sorting arrays
How to call made-up data?
Is the first page of a novel really that important?
Generate random number in Unity without class ambiguity
Ancients don't give a full level?
What are the function of EM and EN spaces?
Could an areostationary satellite help locate asteroids?
What does the ISO setting for mechanical 35mm film cameras actually do?
Description of past perfect tense
Does a humanoid possessed by a ghost register as undead to a paladin's Divine Sense?
How to check a file was encrypted (really & correctly)
Pronouns when writing from the point of view of a robot
Would this winged human/angel be able to fly?
Repeated! Factorials!
How to win against ants
Why are there yellow dot stickers on the front doors of businesses in Russia?
Is a switch from R to Python worth it?
How many years before enough atoms of your body are replaced to survive the sudden disappearance of the original body’s atoms?
Can I enter a rental property without giving notice if I'm afraid a tenant may be hurt?
What is an air conditioner compressor hard start kit and how does it work?
If someone else uploads my GPL'd code to Github without my permission, is that a copyright violation?
Identify Batman without getting caught
Not been paid even after reminding the Treasurer; what should I do?
Why when the leprosy covers the entire body the leper is pronounced pure?
FORMATDATE and format pattern to add year when using format pattern "M"
Sorting a Numpy array by column not axis [duplicate]
Sorting arrays in NumPy by columnHow do I sort a list of dictionaries by a value of the dictionary?Sort a Map<Key, Value> by valuesHow do I sort a dictionary by value?Sorting an array of JavaScript objects by propertySort array of objects by string property valueHow to sort a dataframe by multiple column(s)How to Sort Multi-dimensional Array by Value?Fastest sort of fixed length 6 int arrayNumpy array dimensionsSwift Beta performance: sorting arrays
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
This question already has an answer here:
Sorting arrays in NumPy by column
9 answers
I have a numpy array that is equivalent to:
array([[51, 62, 23],
[24, 45, 16],
[67, 78, 39]])
Just much bigger. I'm trying to sort by the second column (ie. the number 62, 45, 78) but keep the horizontal elements together. The output I'm trying to get would be:
array([[24, 45, 16],
[51, 62, 23],
[67, 78, 39]])
I can't figure out how to do this with np.sort - I don't think this is the correct function for the job (although I'm a bit new to numpy so I might be wrong) - I'm happy to learn a new function, code snippets would be great, but a simple 'use np.blah' would suffice :D
python-3.x numpy sorting
marked as duplicate by cs95
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Mar 27 at 4:06
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Sorting arrays in NumPy by column
9 answers
I have a numpy array that is equivalent to:
array([[51, 62, 23],
[24, 45, 16],
[67, 78, 39]])
Just much bigger. I'm trying to sort by the second column (ie. the number 62, 45, 78) but keep the horizontal elements together. The output I'm trying to get would be:
array([[24, 45, 16],
[51, 62, 23],
[67, 78, 39]])
I can't figure out how to do this with np.sort - I don't think this is the correct function for the job (although I'm a bit new to numpy so I might be wrong) - I'm happy to learn a new function, code snippets would be great, but a simple 'use np.blah' would suffice :D
python-3.x numpy sorting
marked as duplicate by cs95
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Mar 27 at 4:06
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Sorting arrays in NumPy by column
9 answers
I have a numpy array that is equivalent to:
array([[51, 62, 23],
[24, 45, 16],
[67, 78, 39]])
Just much bigger. I'm trying to sort by the second column (ie. the number 62, 45, 78) but keep the horizontal elements together. The output I'm trying to get would be:
array([[24, 45, 16],
[51, 62, 23],
[67, 78, 39]])
I can't figure out how to do this with np.sort - I don't think this is the correct function for the job (although I'm a bit new to numpy so I might be wrong) - I'm happy to learn a new function, code snippets would be great, but a simple 'use np.blah' would suffice :D
python-3.x numpy sorting
This question already has an answer here:
Sorting arrays in NumPy by column
9 answers
I have a numpy array that is equivalent to:
array([[51, 62, 23],
[24, 45, 16],
[67, 78, 39]])
Just much bigger. I'm trying to sort by the second column (ie. the number 62, 45, 78) but keep the horizontal elements together. The output I'm trying to get would be:
array([[24, 45, 16],
[51, 62, 23],
[67, 78, 39]])
I can't figure out how to do this with np.sort - I don't think this is the correct function for the job (although I'm a bit new to numpy so I might be wrong) - I'm happy to learn a new function, code snippets would be great, but a simple 'use np.blah' would suffice :D
This question already has an answer here:
Sorting arrays in NumPy by column
9 answers
python-3.x numpy sorting
python-3.x numpy sorting
asked Mar 27 at 3:39
FraserOfSmegFraserOfSmeg
6921 gold badge14 silver badges27 bronze badges
6921 gold badge14 silver badges27 bronze badges
marked as duplicate by cs95
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Mar 27 at 4:06
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by cs95
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Mar 27 at 4:06
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by cs95
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Mar 27 at 4:06
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
If your numpy array is arr, this should work: arr[arr[:,1].argsort()]
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If your numpy array is arr, this should work: arr[arr[:,1].argsort()]
add a comment |
If your numpy array is arr, this should work: arr[arr[:,1].argsort()]
add a comment |
If your numpy array is arr, this should work: arr[arr[:,1].argsort()]
If your numpy array is arr, this should work: arr[arr[:,1].argsort()]
answered Mar 27 at 3:48
JoshJosh
409 bronze badges
409 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.