แม่แบบ:เรียง
หน้าตา
<span data-sort-value="{{{1}}} !">[[{{{1}}}]]</span>
![]() | แทนที่จะใช้แม่แบบนี้ ควรพิจารณาใช้ data-sort-value เช่น | data-sort-value="Doe, John" | John Doe โปรดดู WP:SORT § Specifying a sort key for a cell สำหรับรายละเอียด |
![]() | มีการใช้แม่แบบนี้ในหลายพันหน้าและการแก้ไขอาจทำให้เกิดผลกระทบหรือสังเกตเห็นได้ ควรทดสอบการเปลี่ยนแปลงในกระบะทราย หรือหน้าทดสอบ หรือในหน้าย่อยผู้ใช้ของคุณเอง อนึ่ง อภิปรายเกี่ยวกับการแก้ไขแม่แบบได้ที่หน้าอภิปรายก่อนที่จะนำไปใช้ |
![]() | แม่แบบนี้ใช้ลูอา |
แม่แบบนี้ใช้สำหรับปรับรูปแบบการเรียงลำดับในตารางที่สามารถเรียงลำดับได้โดยใช้คีย์การเรียงลำดับที่ระบุด้วยตนเอง
- การใช้งาน
{{เรียง | 1 = {{{sort value}}} | 2 = {{{displayed value}}} }}
→ {{{displayed value}}}
พารามิเตอร์แรกคือ sortkey พารามิเตอร์ที่สองคือ wikitext ของสิ่งที่ต้องแสดง โดยค่าเริ่มต้นคือ sortkey พร้อมวงเล็บลิงก์:
{{เรียง | 1 = {{{displayed value}}} }}
→ [[{{{displayed value}}}]]
ตารางที่ใช้แม่แบบนี้ควรใช้ในทุกแถว
แม่แบบนี้ทำงานโดยการเพิ่มค่าการเรียงลำดับแบบซ่อน ซึ่งจะแทนที่ค่าของข้อความที่มองเห็นได้เพื่อจุดประสงค์ในการเรียงลำดับ ผลลัพธ์ HTML จะมีลักษณะดังนี้: <span data-sort-value="sortvalue">[[displayed value]]</span>
.
Example
[แก้]|{{Sort|Brothers Karamazov|[[The Brothers Karamazov]]}}
→ |<span data-sort-value="Brothers Karamazov !">[[The Brothers Karamazov]]</span>
- Sorting by numerical value, date, etc.
- See Help:Sortable tables#Numerical sorting problems and meta:Help:Sorting#Sort modes
- Equal rank
- If you simply code as the second parameter an indicator that two items are equally ranked, e.g. "4=", the template interpreter will treat this as an additional parameter (i.e. parameter 4, which it will then not use). You must explicitly code this as parameter 2:
{{Sort|4|2=4=}}
See also
[แก้]- {{Dsv}} – a shortcut for
data-sort-value="foo"
- {{Sortname}} — for using names in sortable tables (using "last name, first name" as default sort key)
- {{Date table sorting}} — for using dates in sortable tables
- {{Number table sorting}} — for using alphabetic sort mode for numbers in sortable tables
- Help:Sortable tables
- meta:Help:Sorting