diff --git a/howto/sorting.po b/howto/sorting.po index d5f50b1ced..2feb1b11fe 100644 --- a/howto/sorting.po +++ b/howto/sorting.po @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-07-24 00:03+0000\n" -"PO-Revision-Date: 2018-05-23 14:37+0000\n" +"PO-Revision-Date: 2023-08-09 18:16+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -45,12 +45,15 @@ msgid "" "in-place. There is also a :func:`sorted` built-in function that builds a " "new sorted list from an iterable." msgstr "" +"Python 的串列有一個內建的 :meth:`list.sort` 方法可以原地 (in-place) 排序該串" +"列,也有一個內建的 :func:`sorted` 函式可以排序可疊代物件 (iterable) 並建立一" +"個新的排序好的串列。" #: ../../howto/sorting.rst:14 msgid "" "In this document, we explore the various techniques for sorting data using " "Python." -msgstr "在此文件,我們使用Python進行各種方式排序資料" +msgstr "在這份文件裡,我們探索使用 Python 排序資料的各種方法。" #: ../../howto/sorting.rst:18 msgid "Sorting Basics" @@ -61,6 +64,8 @@ msgid "" "A simple ascending sort is very easy: just call the :func:`sorted` function. " "It returns a new sorted list:" msgstr "" +"單純的升冪排序很容易做到:只要呼叫 :func:`sorted` 函式,它會回傳一個新的串" +"列:" #: ../../howto/sorting.rst:28 msgid "" @@ -69,16 +74,21 @@ msgid "" "than :func:`sorted` - but if you don't need the original list, it's slightly " "more efficient." msgstr "" +"你也可以使用 :meth:`list.sort` 方法,它會原地排序串列(並回傳 ``None`` 以避免" +"混淆)。它通常會比 :func:`sorted` 來得不方便——但如果你不需要保留原始串列的" +"話,它會稍微有效率一點。" #: ../../howto/sorting.rst:40 msgid "" "Another difference is that the :meth:`list.sort` method is only defined for " "lists. In contrast, the :func:`sorted` function accepts any iterable." msgstr "" +"另一個差異是 :meth:`list.sort` 方法只有定義在串列上,而 :func:`sorted` 函式可" +"以接受任何可疊代物件。" #: ../../howto/sorting.rst:49 msgid "Key Functions" -msgstr "" +msgstr "鍵函式 (key functions)" #: ../../howto/sorting.rst:51 msgid "" @@ -86,10 +96,12 @@ msgid "" "a function (or other callable) to be called on each list element prior to " "making comparisons." msgstr "" +":meth:`list.sort` 和 :func:`sorted` 都有一個參數 *key* 可以指定一個函式(或其" +"它可呼叫物件 (callable)),這個函式會在每個串列元素做比較前被呼叫。" #: ../../howto/sorting.rst:55 msgid "For example, here's a case-insensitive string comparison:" -msgstr "" +msgstr "例如這裡有一個不區分大小寫的字串比對:" #: ../../howto/sorting.rst:62 msgid "" @@ -98,21 +110,25 @@ msgid "" "This technique is fast because the key function is called exactly once for " "each input record." msgstr "" +"參數 *key* 的值必須是一個函式(或其它可呼叫物件),且這個函式接受單一引數並回" +"傳一個用來排序的鍵。因為對每個輸入來說鍵函式只會被呼叫一次,所以這個做法是快" +"速的。" #: ../../howto/sorting.rst:67 msgid "" "A common pattern is to sort complex objects using some of the object's " "indices as keys. For example:" msgstr "" +"一個常見的模式是在排序複雜物件的時候使用一部分物件的索引值當作鍵,例如:" #: ../../howto/sorting.rst:80 msgid "" "The same technique works for objects with named attributes. For example:" -msgstr "" +msgstr "相同的做法也適用在有命名屬性的物件,例如:" #: ../../howto/sorting.rst:101 msgid "Operator Module Functions" -msgstr "" +msgstr "Operator 模組的函式" #: ../../howto/sorting.rst:103 msgid "" @@ -121,16 +137,20 @@ msgid "" "`operator` module has :func:`~operator.itemgetter`, :func:`~operator." "attrgetter`, and a :func:`~operator.methodcaller` function." msgstr "" +"上述的鍵函式模式非常常見,所以 Python 提供了方便的函式讓物件存取更簡單且快" +"速。:mod:`operator` 模組裡有 :func:`~operator.itemgetter`、:func:" +"`~operator.attrgetter` 及 :func:`~operator.methodcaller` 函式可以使用。" #: ../../howto/sorting.rst:108 msgid "Using those functions, the above examples become simpler and faster:" -msgstr "" +msgstr "使用這些函式讓上面的範例變得更簡單且快速:" #: ../../howto/sorting.rst:120 msgid "" "The operator module functions allow multiple levels of sorting. For example, " "to sort by *grade* then by *age*:" msgstr "" +"operator 模組的函式允許多層的排序,例如先用 *grade* 排序再用 *age* 排序:" #: ../../howto/sorting.rst:132 msgid "Ascending and Descending" @@ -142,10 +162,12 @@ msgid "" "a boolean value. This is used to flag descending sorts. For example, to get " "the student data in reverse *age* order:" msgstr "" +":meth:`list.sort` 和 :func:`sorted` 都有一個 boolean 參數 *reverse* 用來表示" +"是否要降冪排序。例如將學生資料依據 *age* 做降冪排序:" #: ../../howto/sorting.rst:147 msgid "Sort Stability and Complex Sorts" -msgstr "" +msgstr "排序穩定性與複合排序" #: ../../howto/sorting.rst:149 msgid "" @@ -153,12 +175,17 @@ msgid "" "Sorting_algorithm#Stability>`_\\. That means that when multiple records have " "the same key, their original order is preserved." msgstr "" +"排序保證是\\ `穩定的 `_\\ ,意思是當有多筆資料有相同的鍵,它們會維持原" +"來的順序。" #: ../../howto/sorting.rst:159 msgid "" "Notice how the two records for *blue* retain their original order so that " "``('blue', 1)`` is guaranteed to precede ``('blue', 2)``." msgstr "" +"可以注意到有兩筆資料的鍵都是 *blue*,它們會維持本來的順序,即 ``('blue', " +"1)`` 保證在 ``('blue', 2)`` 前面。" #: ../../howto/sorting.rst:162 msgid "" @@ -166,12 +193,17 @@ msgid "" "steps. For example, to sort the student data by descending *grade* and then " "ascending *age*, do the *age* sort first and then sort again using *grade*:" msgstr "" +"這個美妙的特性讓你可以用一連串的排序來作出複合排序。例如對學生資料用 *grade* " +"做降冪排序再用 *age* 做升冪排序,你可以先用 *age* 排序一遍再用 *grade* 排序一" +"遍:" #: ../../howto/sorting.rst:172 msgid "" "This can be abstracted out into a wrapper function that can take a list and " "tuples of field and order to sort them on multiple passes." msgstr "" +"這可以抽出一個包裝函式 (wrapper function),接受一個串列及多個欄位及升降冪的元" +"組為引數,來對這個串列排序多遍。" #: ../../howto/sorting.rst:185 msgid "" @@ -179,6 +211,8 @@ msgid "" "Python does multiple sorts efficiently because it can take advantage of any " "ordering already present in a dataset." msgstr "" +"Python 裡使用的 `Timsort `_ 演算法,因" +"為能利用資料集裡已經有的順序,可以有效率地做多次排序。" #: ../../howto/sorting.rst:190 msgid "Decorate-Sort-Undecorate"