If you need to work with indices of a sequence, then yes – you use it… eg for the equivalent of numpy.argsort…:
>>> a = [6, 3, 1, 2, 5, 4]
>>> sorted(range(len(a)), key=a.__getitem__)
[2, 3, 1, 5, 4, 0]
More Related Contents:
- What happens when start value < end value with range() cmd in Python?
- Is it possible to implement a Python for range loop without an iterator variable?
- How does the Python’s range function work?
- Is it possible to make a `for` loop without an iterator variable? (How can I make make code loop a set number of times?)
- Skip over a value in the range function in python
- Strange result when removing item from a list while iterating over it in Python
- how to can i go over a file twice?
- Why doesn’t this python code run infinite times? [closed]
- Getting the number value of characters in a word and to do arithmetic operations with the number for encoding [closed]
- How on earth does this code work
- How to use a decimal range() step value?
- Is there a way in Pandas to use previous row value in dataframe.apply when previous value is also calculated in the apply?
- How to loop through all but the last item of a list?
- How to access the previous/next element in a for loop?
- for loops and iterating through lists
- `xrange(2**100)` -> OverflowError: long int too large to convert to int
- “for loop” with two variables? [duplicate]
- How to loop backwards in python? [duplicate]
- Python vectorizing nested for loops
- Python range() and zip() object type
- Are infinite for loops possible in Python? [duplicate]
- Why does this python dictionary get created out of order using setdefault()?
- Print a list in reverse order with range()?
- Check presence of vowels in a string
- Python IndexError: list index out of range
- Python: Mapping from intervals to values
- How can I make sense of the `else` clause of Python loops?
- for or while loop to do something n times [duplicate]
- Using a loop in Python to name variables [duplicate]
- How can the built-in range function take a single argument or three?