Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am trying to sort a numpy array using this very simple code:

print np.array([2,0,8,4,1]).sort()

However, I am getting the result:

None

Can someone tell me what's going on here?

share|improve this question

1 Answer 1

up vote 7 down vote accepted

The array probably gets sorted in-place, like Python's list.sort() does so you don't get fooled into thinking the original array is still the same.

arr = np.array([2,0,8,4,1])
arr.sort()
print arr
share|improve this answer
    
ok thanks...... –  user1220022 Apr 12 '12 at 6:54
    
@user1220022: If you just can, please also accept the answer. :) –  AKX Apr 12 '12 at 7:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.