擅长:python、mysql、java
<p>pythons内置的排序函数有一个<code>reverse</code>参数,请参见<a href="https://wiki.python.org/moin/HowTo/Sorting" rel="nofollow noreferrer">https://wiki.python.org/moin/HowTo/Sorting</a>:</p>
<blockquote>
<p>Ascending and Descending</p>
<p>Both <code>list.sort()</code> and <code>sorted()</code> accept a reverse parameter with a
boolean value. This is using to flag descending sorts. For example, to
get the student data in reverse age order:</p>
</blockquote>
<pre><code>sorted(student_tuples, key=itemgetter(2), reverse=True) [('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]
sorted(student_objects, key=attrgetter('age'), reverse=True) [('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]
</code></pre>
<p>在<a href="https://stackoverflow.com/questions/29529641/python-reverse-alphabetical-order">Python reverse alphabetical order</a>中是代码示例</p>