Have a look at the doc for sorted, it’s got an argument for just the occasion.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/c6b0ff1d-5568-4fbb-b553-9fa0b209b959%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
For completeness, the .reverse() method you tried is an “in-place” operator. Meaning it does reverse a list, but does so by modifying the list you call it on, rather than return a new list.
It’s a subtle but important thing.
l = [1, 2, 3]
assert l[0] == 1
l.reverse()
assert l[0] == 3
l = l.reverse()
assert l == None
Then there’s reversed too.
l = reversed([1, 2, 3])
l[0]
# ERROR, it's an "iterator"
l = list(l)
assert l[0] == 3
Thanks. so the syntax is: order = sorted(wordFrequencey.values(),reverse=True)
On Tuesday, September 26, 2017 at 9:29:54 AM UTC-7, Marcus Ottosson wrote:
Have a look at the doc for
sorted, it’s got an argument for just the occasion.
On 26 September 2017 at 17:04, jettam <justin...@gmail.com> wrote:
This command sorts the values of my dictionary into a numerical order. I now would like to reverse that numerical order. I can see there is a command called .reverse() that I should be able to include.But I have tried all kinds of ways to include it, I just cant get it to work. Could someone advise of the correct syntax.wordFrequencey = { 'ARE': 1, 'ART': 2, 'AS': 8, 'AT': 3, 'ATTEMPT': 2, 'AVERSION': 4, 'AWARE': 1, 'AWARENESS': 1}order = sorted(wordFrequencey.values())
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/c6b0ff1d-5568-4fbb-b553-9fa0b209b959%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/cdc5feba-4029-4967-a77a-3a4bde7f9e48%40googlegroups.com.