Solved

reversing output of numpy argsort

Posted on 2013-06-20
7
1,419 Views
Last Modified: 2013-06-25
Hi,

I find it amazing that I can't find an answer online, but how do I use numpy argsort to sort in reverse order?  The documentation is sparse.

I'm sorting a simple array of numbers and need the sorted index values in descending order.

ideas?

Thanks!
0
Comment
Question by:ugeb
  • 4
  • 3
7 Comments
 
LVL 23

Expert Comment

by:tailoreddigital
Comment Utility
I don't know a lot about Python, but ran across this, so i thought i'd toss it at you,

L2.reverse()

I grabbed this from page 17,
http://koen.me/research/teaching-asci/python-workshop-slides.pdf
0
 
LVL 11

Author Comment

by:ugeb
Comment Utility
Thanks, but that has nothing to do with numpy's argsort.  That's plain python but I'm using numpy's data structure.
0
 
LVL 23

Expert Comment

by:tailoreddigital
Comment Utility
I apologise if i'm barking up the wrong tree, just trying to help,

Take a look here,
http://stackoverflow.com/questions/8445323/reverse-sort-and-argsort-in-python

This seems to be a solution.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 11

Author Comment

by:ugeb
Comment Utility
Thanks, but I've been through all these pages already through extensive searching, and they don't address the actual issue. None of the pages I've found have answered my question.
0
 
LVL 23

Expert Comment

by:tailoreddigital
Comment Utility
I wish i could help further but i can't. Hopefully another more qualified expert will help out.

Good luck.
0
 
LVL 11

Accepted Solution

by:
ugeb earned 0 total points
Comment Utility
Thanks anyway.  I'm having to take the longer path of converting to a list and then reversing, instead of the far more efficient path of argsort actually having a reverse argument!  Oh well.
0
 
LVL 11

Author Closing Comment

by:ugeb
Comment Utility
Thanks anyway.  I'm having to take the longer path of converting to a list and then reversing, instead of the far more efficient path of argsort actually having a reverse argument!  Oh well.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Less strange, but still introduction This introduction was added (1st August, 2011) to reflect some reactions.  Firstly, the term basics in the title of the article...  As any other word, it is a symbol with meaning attached to the word by some a…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now