@@ -116,12 +116,15 @@ msgid ""
116
116
"*key* parameter to specify a function (or other callable) to be called on "
117
117
"each list element prior to making comparisons."
118
118
msgstr ""
119
+ ":meth:`list.sort` 方法以及 :func:`sorted`, :func:`min`, :func:`max`, "
120
+ ":func:`heapq.nsmallest` 和 :func:`heapq.nlargest` 等函数都有一个 *key* "
121
+ "形参用以指定要在进行比较之前对每个列表元素调用的函数(或其它可调用对象)。"
119
122
120
123
#: ../../howto/sorting.rst:56
121
124
msgid ""
122
125
"For example, here's a case-insensitive string comparison using "
123
126
":meth:`str.casefold`:"
124
- msgstr ""
127
+ msgstr "例如,下面是使用 :meth:`str.casefold` 进行不区分大小写的字符串比较: "
125
128
126
129
#: ../../howto/sorting.rst:59
127
130
msgid ""
@@ -549,27 +552,30 @@ msgstr "不可排序类型和值的策略"
549
552
msgid ""
550
553
"A number of type and value issues can arise when sorting. Here are some "
551
554
"strategies that can help:"
552
- msgstr ""
555
+ msgstr "在排序时可能出现多种涉及类型和值的问题。 下面是一些有助于解决问题的策略: "
553
556
554
557
#: ../../howto/sorting.rst:284
555
558
msgid "Convert non-comparable input types to strings prior to sorting:"
556
- msgstr ""
559
+ msgstr "在排序之前将不可比较的输入类型转换为字符串。 "
557
560
558
561
#: ../../howto/sorting.rst:286
559
562
msgid ""
560
563
">>> data = ['twelve', '11', 10]\n"
561
564
">>> sorted(map(str, data))\n"
562
565
"['10', '11', 'twelve']"
563
566
msgstr ""
567
+ ">>> data = ['twelve', '11', 10]\n"
568
+ ">>> sorted(map(str, data))\n"
569
+ "['10', '11', 'twelve']"
564
570
565
571
#: ../../howto/sorting.rst:292
566
572
msgid ""
567
573
"This is needed because most cross-type comparisons raise a :exc:`TypeError`."
568
- msgstr ""
574
+ msgstr "需要这样做是因为大多数跨类型比较都会引发 :exc:`TypeError`。 "
569
575
570
576
#: ../../howto/sorting.rst:295
571
577
msgid "Remove special values prior to sorting:"
572
- msgstr ""
578
+ msgstr "在排序之前移除特殊的值: "
573
579
574
580
#: ../../howto/sorting.rst:297
575
581
msgid ""
@@ -579,6 +585,11 @@ msgid ""
579
585
">>> sorted(filterfalse(isnan, data))\n"
580
586
"[1.1, 2.2, 3.3]"
581
587
msgstr ""
588
+ ">>> from math import isnan\n"
589
+ ">>> from itertools import filterfalse\n"
590
+ ">>> data = [3.3, float('nan'), 1.1, 2.2]\n"
591
+ ">>> sorted(filterfalse(isnan, data))\n"
592
+ "[1.1, 2.2, 3.3]"
582
593
583
594
#: ../../howto/sorting.rst:305
584
595
msgid ""