Help:Sortable tables/fa

PD توجه: شما در هنگام ویرایش این صفحه، موافق با انتشار مشارکت‌هایتان تحت CC0 هستید. صفحه‌های راهنمای مالکیت عمومی را برای اطلاعات بیشتر ببینید. PD

To make a sortable table, add the sortable class to a table. This class adds arrows displayed beside the header within each header cell. (See example below.) When you click on an arrow, the table rows are arranged according to the chosen column. Continuously clicking the arrow alters the sorting order in the following pattern: Ascending (min to max), Descending (max to min), and then Unsorted (sequential). You can perform secondary sorts by shift-clicking the arrows in different columns.

Each shift click will set the secondary sort based on the clicked column, and this capability extends to tertiary and further sorts.

Sort modes

Items are sorted based on the data type of the first few rows below the header. To determine the data type, the first five non-empty rows below the header are examined upon page loading, and the most suitable format is selected. Discrepancies can occur. Additionally, specific columns can have their sorting order forced, as explained in the relevant section below.

Currently, tags like span or sup don't affect how data types are determined, but reference numbers and visible comments do.

Dates

Different date formats are accepted, even those with month names in local languages. For instance, on the German Wikipedia, "16. März 2010" is appropriately sorted as 2010-03-16.

Different numerical formats, including ones with various separators like periods, commas, apostrophes, or slashes (such as . , ' /), are supported. The English Wikipedia typically uses the US date format, (e.g. month-day-year).

Numbers

The script can detect numbers that use either "." or "," as decimal separators, as well as numbers written in scientific notation (using "e" or "E"). By default, numbers will be sorted based on alphanumeric order by default, meaning that they will be sorted as strings rather than numerical values. This may result in unexpected sortings, such as "9" coming after "10". However, this default behavior can be overridden if desired.

Text

When lists are sorted alphabetically by MediaWiki, the order of characters is sorted with Intl.Collator. This sorts accented characters correctly based on PageContentLanguage.

Android Webviews don't support this, so fallback to the old sort routine is required. The order is the same as the order of Unicode code points. Some of the more common characters are ordered as follows (in ascending order):

 
 !"#$ %&'()*+,-./0123456789 : ;<=> ?@ABC
DEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefg
hijklmnopqrstuvwxyz{|}~
 
¡¢£¤¥¦§¨©ª« ¬
­
®¯°±²³´µ·¸¹º »¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐ
ÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóô
õö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘ
ęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļ
ĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠ
šŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƏƒǺǻǼ
ǽǾǿȘșȚțəˆˇˉ˘˙˚˛˜˝΄΅Ά·ΈΉΊΌΎΏΐΑΒΓΔΕΖΗΘ
ΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμν
ξοπρςστυφχψωϊϋόύώЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВ
ГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеж
зийклмнопрстуфхцчшщъыьэюяѐёђѓєѕіїјљњ
ћќѝўџҐґ
  Ω

Forcing the sort mode of a column

Adding data-sort-type="..." to the header lets you control how a table is sorted. This feature is derived from tablesorter.com (webarchive). Valid values for "data-sort-type" include the following which are not case-sensitive:

  • currency
  • number
  • isoDate
  • time
  • IPAddress
  • usLongDate
  • date
  • text
  • url

For example:

Wikitext

{|class="wikitable sortable"
!data-sort-type="date"| Date !! Name !! Height !!data-sort-type="number"| Salary
|-
| 01.10.1977 || Smith || 1.85 || 1,000.000
|-
| 11.6.1972 || Ray || 1.89 || 900.000
|-
| 1.9.1992 || Bianchi || 1.72 || 2,000.50
|}

Rendering

DateNameHeightSalary
01.10.1977Smith1.851,000.000
11.6.1972Ray1.89900.000
1.9.1992Bianchi1.722,000.50

Specifying a sort key

You can adjust how cells are sorted or parsed if needed. For instance, if a cell says "John Smith" but should be sorted under "Smith", you can use the data-sort-value="..." attribute to achieve this.

Wikitext

{|class="wikitable sortable"
! Name and Surname !! Height
|-
|data-sort-value="Smith, John"| John Smith || 1.85
|-
|data-sort-value="Ray, Ian"| Ian Ray || 1.89
|-
|data-sort-value="Bianchi, Zachary"| Zachary Bianchi || 1.72
|}

Rendering

Name and SurnameHeight
John Smith1.85
Ian Ray1.89
Zachary Bianchi1.72

Controlling sorting and display

To ensure certain text isn't sorted but still displayed, use data-sort-type="...". You can then append additional text after values, like "200 approx" or "100<sup style="color:blue" title="link to Reference">[1]". An empty cell sorts as "-Infinity". If a cell contains a range of dates or numbers (for example, from 2 to 5), use data-sort-value="...".

Examples

The first column sorts plain numbers. The second column sorts more content as numbers using data-sort-type="number" in the table header. The fourth column defines numeric sort values independently of cell content using data-sort-value="...".

numbers data-sort-type="number" data-sort-type="number"
-8e3-8 e3-8 e3
-3e-3-3 e-3-3 e-3
2.0002-5 km²data-sort-value="3.5"2-5 km²
3.993.99 km²3.99 km²
44 km²4 km²
90 %90 Percentdata-sort-value="90"about 90 Percent
1E2100[1]100[1]
1,000,000.01 000 000.0data-sort-value="1e6"one Million

The way commas (,) and decimal points (.) are displayed in Mediawiki depends on the language settings. Currency symbols and the percentage (%) symbol are sorted numerically based on these settings.

currencies
$ 9
$ 80
$ 70
$ 600
currencies
9 €
80 €
70 €
600 €
currencies
£ 9
£ 80
£ 70
£ 600
currencies
¥ 9
¥ 80
¥ 70
¥ 600
percent
9 %
80 %
70 %
600 %
numbers
−7e270
-1.4285714285714E-13
999e9
7e270

Secondary sort key

You can sort data by columns, with Column A as the primary sort key. If Column A has equal values, use Column B as the secondary key. Click Column A's sort button once or twice, then while holding shift, click Column B's sort button once or twice for further refinement.

For example:

Click on the "Text" column first, then hold down the shift key and click on the "Numbers" column. You'll notice that the items are sorted based on text first and then numbers.

Numbers Text Dates Currency More text
4a01.Jan.20054.20row 1
5a05/12/20067.15row 2
1b02-02-20045.00row 3
1a02-02-20045.00row 4
2x13-apr-2005row 5
2a13-apr-2005row 6
3a17.aug.20066.50row 7
3z25.aug.20062.30row 8
3z28.aug.20065.50row 9
3z31.aug.20063.77row 10
3z01.sep.20061.50row 11
Bottom

Additional features

Excluding the last row from sorting

You can skip sorting the last row of a table by marking it with class="sortbottom". You can also exclude it from sorting by declaring it as a footer with an exclamation mark (!).

Wikitext

{|class="wikitable sortable"
! Name !! Surname !! Height
|-
| John || Smith || 1.85
|-
| Ron || Ray || 1.89
|-
| Mario || Bianchi || 1.72
|- class="sortbottom"
! !! Average: || 1.82
|}

Rendering

NameSurnameHeight
JohnSmith1.85
RonRay1.89
MarioBianchi1.72
Average:1.82

Excluding the first row from sorting

You can exclude the first row by using the class="sorttop".

Wikitext

{|class="wikitable sortable"
! Name !! Surname !! Height
|- class="sorttop"
! !! Average: || 1.82
|-
| John || Smith || 1.85
|-
| Ron || Ray || 1.89
|-
| Mario || Bianchi || 1.72
|}

Rendering

NameSurnameHeight
Average:1.82
JohnSmith1.85
RonRay1.89
MarioBianchi1.72

Making a column unsortable

To stop a column from being sortable, use class="unsortable" in its header cell's attributes.

Wikitext

{|class="wikitable sortable"
! Numbers !! Alphabet !! Dates !! Currency !!class="unsortable"| Unsortable
|-
| 1 || Z || 02-02-2004 || 5.00 || This
|-
| 2 || y || 13-apr-2005 || || Column
|-
| 3 || X || 17.aug.2006 || 6.50 || Is
|-
| 4 || w || 01.Jan.2005 || 4.20 || Unsortable
|-
| 5 || V || 05/12/2006 || 7.15 || See?
|-
! Total: 15 !! !! !! Total: 29.55 !!
|-
|}

Rendering

NumbersAlphabetDatesCurrencyUnsortable
1Z02-02-20045.00This
2y13-apr-2005Column
3X17.aug.20066.50Is
4w01.Jan.20054.20Unsortable
5V05/12/20067.15See?
Total: 15Total: 29.55Original example

Keeping some rows together

To allow an uncolumned row to always stay beneath the columned row above it, no matter how you sort them, use class="expand-child" in the row's attribute.

Wikitext

{| class="wikitable sortable"
!style="width:9em"| Country !!data-sort-type="number"| Area
|-
| France
| 674 843 km²
|- class="expand-child" style="font-size:85%; line-height:1.2; color:gray"
|colspan="2"| In Paris is the Eiffel Tower.
|-
| U.K.
| 242 495 km²
|- class="expand-child" style="font-size:85%; line-height:1.2; color:gray"
|colspan="2"| In the U.K. you cannot pay with euros.
|- class="expand-child" style="font-size:85%; line-height:1.2; color:gray"
|colspan="2"| And you drive on the left side of the road.
|-
| Germany
| 357 168 km²
|- class="expand-child" style="font-size:85%; line-height:1.2; color:gray"
|colspan="2"| Germany includes the former DDR.
|}

Rendering

CountryArea
France 674 843 km²
In Paris is the Eiffel Tower.
U.K. 242 495 km²
In the U.K. you cannot pay with euros.
And you drive on the left side of the road.
Germany 357 168 km²
Germany includes the former DDR.

If you put in data-sort-value the same content as above row, keep this rows also together. The original mutual order of these rows is preserved. A better way for this is class expand-child, see above #Keeping some rows together.

Example where data-sort-value is used is the case for the rows about the Netherlands:

{|class="wikitable sortable"
! Country/province !! Capital
|-
| France || Paris
|-
| Netherlands || Amsterdam
|-
|data-sort-value="Netherlands"| South Holland ||data-sort-value="Amsterdam"| The Hague
|-
| U.K. || London
|}
Country/provinceCapital
FranceParis
NetherlandsAmsterdam
South HollandThe Hague
U.K.London

Special dates

To represent years Before the Common Era (BCE) subtract the BCE year from ۱۰٬۰۰۰. For instance, -62 BCE would be ۱۰٬۰۰۰ - 62 = 9938.

For example, September 23, 62 BCE would be represented as 9938-09-23.

If a table column has incomplete dates, sorting won't be an issue. If only a year and month are provided, it's sorted before the first day of that month. Similarly, if only a year is given, it's sorted before the first month or day of that year.

Wikitext

{| class="wikitable sortable"
|-
! Date
|-
| 2022-01-01
|-
| 2023-12-31
|-
| 2024
|-
| 2024-04
|-
| 2024-04-00
|-
| 2024-05
|-
| 2024-05-00
|}

Rendering

Date
2022-01-01
2023-12-31
2024
2024-04
2024-04-00
2024-05
2024-05-00

Using #time

You can use the parser function #time and HTML tags to display a specific date range. By adding the HTML tag <span style="display:none">&{{#expr:3e11+{{#time:U|..}}}}</span> before the displayed date, you can manipulate the way the date is shown. This method works for dates between January 1, 111 CE, and December 31, 9999 CE, using the proleptic Gregorian calendar. The added value ensures all values are positive and uniform in length. Placing "&" before the expression forces string sorting mode.

You can input dates and times using any PHP format for date and time. Remember, if you're specifying just a year, you must include a month (usually January) in the background.

For example using date:

input date text date and time as interpreted, with hidden sort key input with visible sort key input with hidden sort key Unix time
010203&Expression error: Unrecognized punctuation character "۱". ۱۰ مه ۲۰۲۵ ۰۱:۰۲:۰۳&Expression error: Unrecognized punctuation character "۱". 010203&Expression error: Unrecognized punctuation character "۱". 010203۱۷۴۶۸۳۸۹۲۳
1/2&Expression error: Unrecognized punctuation character "۱". ۰۲ ژانویه ۲۰۲۵ ۰۰:۰۰:۰۰&Expression error: Unrecognized punctuation character "۱". 1/2&Expression error: Unrecognized punctuation character "۱". 1/2۱۷۳۵۷۷۶۰۰۰
1/2/3&Expression error: Unrecognized punctuation character "۱". ۰۲ ژانویه ۲۰۰۳ ۰۰:۰۰:۰۰&Expression error: Unrecognized punctuation character "۱". 1/2/3&Expression error: Unrecognized punctuation character "۱". 1/2/3۱۰۴۱۴۶۵۶۰۰
1-2-2003&Expression error: Unrecognized punctuation character "۱". ۰۱ فوریه ۲۰۰۳ ۰۰:۰۰:۰۰&Expression error: Unrecognized punctuation character "۱". 1-2-2003&Expression error: Unrecognized punctuation character "۱". 1-2-2003۱۰۴۴۰۵۷۶۰۰
1-2-3&Expression error: Unrecognized punctuation character "۹". ۰۳ فوریه ۲۰۰۱ ۰۰:۰۰:۰۰&Expression error: Unrecognized punctuation character "۹". 1-2-3&Expression error: Unrecognized punctuation character "۹". 1-2-3۹۸۱۱۵۸۴۰۰
2007&Expression error: Unrecognized punctuation character "۱". ۰۱ ژانویه ۲۰۰۷ ۰۰:۰۰:۰۰&Expression error: Unrecognized punctuation character "۱". 2007&Expression error: Unrecognized punctuation character "۱". 2007۱۱۶۷۶۰۹۶۰۰
1 Jan 111, 00:00:00&241335609600 ۰۱ ژانویه ۰۱۱۱ ۰۰:۰۰:۰۰&241335609600 1 Jan 111, 00:00:00&241335609600 1 Jan 111, 00:00:00-58664390400
31 Dec 9999, 23:59:59&Expression error: Unrecognized punctuation character "۲". ۳۱ دسامبر ۹۹۹۹ ۲۳:۵۹:۵۹&Expression error: Unrecognized punctuation character "۲". 31 Dec 9999, 23:59:59&Expression error: Unrecognized punctuation character "۲". 31 Dec 9999, 23:59:59۲۵۳۴۰۲۳۰۰۷۹۹
Sep 1970&Expression error: Unrecognized punctuation character "۲". ۰۱ سپتامبر ۱۹۷۰ ۰۰:۰۰:۰۰&Expression error: Unrecognized punctuation character "۲". Sep 1970&Expression error: Unrecognized punctuation character "۲". Sep 1970۲۰۹۹۵۲۰۰
1970&Expression error: Unrecognized punctuation character "۰". ۰۱ ژانویه ۱۹۷۰ ۰۰:۰۰:۰۰&Expression error: Unrecognized punctuation character "۰". 1970&Expression error: Unrecognized punctuation character "۰". 1970۰
Jun 2007or later&Expression error: Unrecognized punctuation character "۱". ۰۱ ژوئن ۲۰۰۷ ۰۰:۰۰:۰۰ or later&Expression error: Unrecognized punctuation character "۱". Jun 2007 or later&Expression error: Unrecognized punctuation character "۱". Jun 2007 or later۱۱۸۰۶۵۶۰۰۰ or later
Jun 2007perhaps earlier&Expression error: Unrecognized punctuation character "۱". ۰۱ ژوئن ۲۰۰۷ ۰۰:۰۰:۰۰ perhaps earlier&Expression error: Unrecognized punctuation character "۱". Jun 2007 perhaps earlier&Expression error: Unrecognized punctuation character "۱". Jun 2007 perhaps earlier۱۱۸۰۶۵۶۰۰۰ perhaps earlier
2007-6&Expression error: Unrecognized punctuation character "۱". ۰۱ ژوئن ۲۰۰۷ ۰۰:۰۰:۰۰&Expression error: Unrecognized punctuation character "۱". 2007-6&Expression error: Unrecognized punctuation character "۱". 2007-6۱۱۸۰۶۵۶۰۰۰
Jun 2007&Expression error: Unrecognized punctuation character "۱". ۰۱ ژوئن ۲۰۰۷ ۰۰:۰۰:۰۰&Expression error: Unrecognized punctuation character "۱". Jun 2007&Expression error: Unrecognized punctuation character "۱". Jun 2007۱۱۸۰۶۵۶۰۰۰
4 Jun 2007&Expression error: Unrecognized punctuation character "۱". ۰۴ ژوئن ۲۰۰۷ ۰۰:۰۰:۰۰&Expression error: Unrecognized punctuation character "۱". 4 Jun 2007&Expression error: Unrecognized punctuation character "۱". 4 Jun 2007۱۱۸۰۹۱۵۲۰۰
3 Jul 2007&Expression error: Unrecognized punctuation character "۱". ۰۳ ژوئیه ۲۰۰۷ ۰۰:۰۰:۰۰&Expression error: Unrecognized punctuation character "۱". 3 Jul 2007&Expression error: Unrecognized punctuation character "۱". 3 Jul 2007۱۱۸۳۴۲۰۸۰۰
12 Aug 2006&Expression error: Unrecognized punctuation character "۱". ۱۲ اوت ۲۰۰۶ ۰۰:۰۰:۰۰&Expression error: Unrecognized punctuation character "۱". 12 Aug 2006&Expression error: Unrecognized punctuation character "۱". 12 Aug 2006۱۱۵۵۳۴۰۸۰۰
1 Mar 2006 -1day&Expression error: Unrecognized punctuation character "۱". ۲۸ فوریه ۲۰۰۶ ۰۰:۰۰:۰۰&Expression error: Unrecognized punctuation character "۱". 1 Mar 2006 -1day&Expression error: Unrecognized punctuation character "۱". 1 Mar 2006 -1day۱۱۴۱۰۸۴۸۰۰
1 Mar 2008 -1day&Expression error: Unrecognized punctuation character "۱". ۲۹ فوریه ۲۰۰۸ ۰۰:۰۰:۰۰&Expression error: Unrecognized punctuation character "۱". 1 Mar 2008 -1day&Expression error: Unrecognized punctuation character "۱". 1 Mar 2008 -1day۱۲۰۴۲۴۳۲۰۰
1 Mar 2010 -1day&Expression error: Unrecognized punctuation character "۱". ۲۸ فوریه ۲۰۱۰ ۰۰:۰۰:۰۰&Expression error: Unrecognized punctuation character "۱". 1 Mar 2010 -1day&Expression error: Unrecognized punctuation character "۱". 1 Mar 2010 -1day۱۲۶۷۳۱۵۲۰۰
1 Mar 1900 -1day&297796022400 ۲۸ فوریه ۱۹۰۰ ۰۰:۰۰:۰۰&297796022400 1 Mar 1900 -1day&297796022400 1 Mar 1900 -1day-2203977600
1 Mar 1600 -1day&288329001600 ۲۹ فوریه ۱۶۰۰ ۰۰:۰۰:۰۰&288329001600 1 Mar 1600 -1day&288329001600 1 Mar 1600 -1day-11670998400
Jun 1607&288557875200 ۰۱ ژوئن ۱۶۰۷ ۰۰:۰۰:۰۰&288557875200 Jun 1607&288557875200 Jun 1607-11442124800
20250510091239&Expression error: Unrecognized punctuation character "۱". ۱۰ مه ۲۰۲۵ ۰۹:۱۲:۳۹&Expression error: Unrecognized punctuation character "۱". 20250510091239&Expression error: Unrecognized punctuation character "۱". 20250510091239۱۷۴۶۸۶۸۳۵۹
yesterday&Expression error: Unrecognized punctuation character "۱". ۰۹ مه ۲۰۲۵ ۰۰:۰۰:۰۰&Expression error: Unrecognized punctuation character "۱". yesterday&Expression error: Unrecognized punctuation character "۱". yesterday۱۷۴۶۷۴۸۸۰۰
today&Expression error: Unrecognized punctuation character "۱". ۱۰ مه ۲۰۲۵ ۰۰:۰۰:۰۰&Expression error: Unrecognized punctuation character "۱". today&Expression error: Unrecognized punctuation character "۱". today۱۷۴۶۸۳۵۲۰۰
tomorrow&Expression error: Unrecognized punctuation character "۱". ۱۱ مه ۲۰۲۵ ۰۰:۰۰:۰۰&Expression error: Unrecognized punctuation character "۱". tomorrow&Expression error: Unrecognized punctuation character "۱". tomorrow۱۷۴۶۹۲۱۶۰۰
1week&Expression error: Unrecognized punctuation character "۱". ۱۷ مه ۲۰۲۵ ۰۹:۱۲:۴۰&Expression error: Unrecognized punctuation character "۱". 1week&Expression error: Unrecognized punctuation character "۱". 1week۱۷۴۷۴۷۳۱۶۰
-1week&Expression error: Unrecognized punctuation character "۱". ۰۳ مه ۲۰۲۵ ۰۹:۱۲:۴۰&Expression error: Unrecognized punctuation character "۱". -1week&Expression error: Unrecognized punctuation character "۱". -1week۱۷۴۶۲۶۳۵۶۰
1day&Expression error: Unrecognized punctuation character "۱". ۱۱ مه ۲۰۲۵ ۰۹:۱۲:۴۰&Expression error: Unrecognized punctuation character "۱". 1day&Expression error: Unrecognized punctuation character "۱". 1day۱۷۴۶۹۵۴۷۶۰
-1day&Expression error: Unrecognized punctuation character "۱". ۰۹ مه ۲۰۲۵ ۰۹:۱۲:۴۰&Expression error: Unrecognized punctuation character "۱". -1day&Expression error: Unrecognized punctuation character "۱". -1day۱۷۴۶۷۸۱۹۶۰
1month&Expression error: Unrecognized punctuation character "۱". ۱۰ ژوئن ۲۰۲۵ ۰۹:۱۲:۴۰&Expression error: Unrecognized punctuation character "۱". 1month&Expression error: Unrecognized punctuation character "۱". 1month۱۷۴۹۵۴۶۷۶۰
-1month&Expression error: Unrecognized punctuation character "۱". ۱۰ آوریل ۲۰۲۵ ۰۹:۱۲:۴۰&Expression error: Unrecognized punctuation character "۱". -1month&Expression error: Unrecognized punctuation character "۱". -1month۱۷۴۴۲۷۶۳۶۰
1year&Expression error: Unrecognized punctuation character "۱". ۱۰ مه ۲۰۲۶ ۰۹:۱۲:۴۰&Expression error: Unrecognized punctuation character "۱". 1year&Expression error: Unrecognized punctuation character "۱". 1year۱۷۷۸۴۰۴۳۶۰
-1year&Expression error: Unrecognized punctuation character "۱". ۱۰ مه ۲۰۲۴ ۰۹:۱۲:۴۰&Expression error: Unrecognized punctuation character "۱". -1year&Expression error: Unrecognized punctuation character "۱". -1year۱۷۱۵۳۳۲۳۶۰
1000year&Expression error: Unrecognized punctuation character "۳". ۱۰ مه ۳۰۲۵ ۰۹:۱۲:۴۰&Expression error: Unrecognized punctuation character "۳". 1000year&Expression error: Unrecognized punctuation character "۳". 1000year۳۳۳۰۳۷۷۷۱۶۰
10000month&Expression error: Unrecognized punctuation character "۲". ۱۰ سپتامبر ۲۸۵۸ ۰۹:۱۲:۴۰&Expression error: Unrecognized punctuation character "۲". 10000month&Expression error: Unrecognized punctuation character "۲". 10000month۲۸۰۴۴۴۳۶۳۶۰
1000000day&Expression error: Unrecognized punctuation character "۸". ۰۷ آوریل ۴۷۶۳ ۰۹:۱۲:۴۰&Expression error: Unrecognized punctuation character "۸". 1000000day&Expression error: Unrecognized punctuation character "۸". 1000000day۸۸۱۴۶۸۶۸۳۶۰
10000000hour&Expression error: Unrecognized punctuation character "۳". ۲۵ فوریه ۳۱۶۶ ۰۱:۱۲:۴۰&Expression error: Unrecognized punctuation character "۳". 10000000hour&Expression error: Unrecognized punctuation character "۳". 10000000hour۳۷۷۴۶۸۶۸۳۶۰
1000000000minute&Expression error: Unrecognized punctuation character "۶". ۰۶ سپتامبر ۳۹۲۶ ۱۹:۵۲:۴۰&Expression error: Unrecognized punctuation character "۶". 1000000000minute&Expression error: Unrecognized punctuation character "۶". 1000000000minute۶۱۷۴۶۸۶۸۳۶۰
100000000000second&Expression error: Unrecognized punctuation character "۱". ۲۵ مارس ۵۱۹۴ ۱۸:۵۹:۲۰&Expression error: Unrecognized punctuation character "۱". 100000000000second&Expression error: Unrecognized punctuation character "۱". 100000000000second۱۰۱۷۴۶۸۶۸۳۶۰
7980year&Expression error: Unexpected < operator. خطا: #زمان تا سال ۹۹۹۹ را فقط حمایت می‌کند.&Expression error: Unexpected < operator. 7980year&Expression error: Unexpected < operator. 7980yearخطا: #زمان تا سال ۹۹۹۹ را فقط حمایت می‌کند.
-1890year&242104170760 ۱۰ مه ۰۱۳۵ ۰۹:۱۲:۴۰&242104170760 -1890year&242104170760 -1890year-57895829240
Mon&Expression error: Unrecognized punctuation character "۱". ۱۲ مه ۲۰۲۵ ۰۰:۰۰:۰۰&Expression error: Unrecognized punctuation character "۱". Mon&Expression error: Unrecognized punctuation character "۱". Mon۱۷۴۷۰۰۸۰۰۰
Tue&Expression error: Unrecognized punctuation character "۱". ۱۳ مه ۲۰۲۵ ۰۰:۰۰:۰۰&Expression error: Unrecognized punctuation character "۱". Tue&Expression error: Unrecognized punctuation character "۱". Tue۱۷۴۷۰۹۴۴۰۰
Wed&Expression error: Unrecognized punctuation character "۱". ۱۴ مه ۲۰۲۵ ۰۰:۰۰:۰۰&Expression error: Unrecognized punctuation character "۱". Wed&Expression error: Unrecognized punctuation character "۱". Wed۱۷۴۷۱۸۰۸۰۰
Thu&Expression error: Unrecognized punctuation character "۱". ۱۵ مه ۲۰۲۵ ۰۰:۰۰:۰۰&Expression error: Unrecognized punctuation character "۱". Thu&Expression error: Unrecognized punctuation character "۱". Thu۱۷۴۷۲۶۷۲۰۰
Fri&Expression error: Unrecognized punctuation character "۱". ۱۶ مه ۲۰۲۵ ۰۰:۰۰:۰۰&Expression error: Unrecognized punctuation character "۱". Fri&Expression error: Unrecognized punctuation character "۱". Fri۱۷۴۷۳۵۳۶۰۰
Sat&Expression error: Unrecognized punctuation character "۱". ۱۰ مه ۲۰۲۵ ۰۰:۰۰:۰۰&Expression error: Unrecognized punctuation character "۱". Sat&Expression error: Unrecognized punctuation character "۱". Sat۱۷۴۶۸۳۵۲۰۰
Sun&Expression error: Unrecognized punctuation character "۱". ۱۱ مه ۲۰۲۵ ۰۰:۰۰:۰۰&Expression error: Unrecognized punctuation character "۱". Sun&Expression error: Unrecognized punctuation character "۱". Sun۱۷۴۶۹۲۱۶۰۰
&Expression error: Unexpected < operator. خطا: زمان نامعتبر&Expression error: Unexpected < operator.&Expression error: Unexpected < operator. خطا: زمان نامعتبر
unknown&Expression error: Unexpected < operator. خطا: زمان نامعتبر&Expression error: Unexpected < operator. unknown&Expression error: Unexpected < operator. unknownخطا: زمان نامعتبر

To use dates before 111 CE, add a multiple of 400 (like 6000) to all years. This shifts the range to start from January 1st, -5889, at 00:00:00, and ends on December 31st, 3999, at 23:59:59, without altering the calendar system.

See also:

Cell spanning multiple rows/cells

A cell that extends across multiple rows or columns is considered equivalent to having multiple cells with identical values.

rowspan
DateNameHeight
01.10.1977Smith1.85
11.06.1972Adams
01.09.1992Bianchi1.72
colspan
ABC
A 2 1
B 1 3
C 2

Any missing cells at the end of a row will turn into empty cells after the first sort.

Colspanned cells

Sort modes are detected separately for each column containing colspanned cells. You can set a sort mode for all colspanned columns by including data-sort-type in the header.

To implement separate sort keys for each column within a colspanned cell, utilize a CSS trick described here: Ensure an equal number of cells in each row for sortable columns. If there's a mismatch, all columns become sortable. This rule should apply up to and including the last sortable column. However, employing a CSS workaround allows for a difference between the displayed number of cells in a row and the formal count. For instance, two formal cells can appear as one by adjusting the width of the first column, shifting the content of the second cell to the left, increasing its width by the same measure, and concealing the cell border that would typically be visible. Concealed sort keys enable managing the sorting order of specific rows in relation to each column.

For example:

CountryCapital
France Paris
Sorting with respect to the first column this row sorts like Z, with respect to the second column like M
U.K. London

Static column

To make a static column, like one with row numbers, use two tables placed next to each other. Make sure each row in both tables has the same height. You can also use w:Template:Static row numbers to generate row numbers implicitly using CSS rather than creating another table.

Number
1
2
CountryCapital
The NetherlandsAmsterdam (although The Hague is the seat of government)
FranceParis

The formatting can be modified to present everything in a unified table. If a row is too short for the text in a cell, the browser will expand it, disrupting the alignment.

Default order

You can't show a table sorted by a column without the user clicking on it. By default, table rows appear in the order as the wikitext. To display a table sorted by a specific column, you'll need to arrange the wikitext accordingly. One way of doing this is:

  1. Rearrange the table's wikitext without the top and bottom lines.
  2. Replace the cell separators with a unique code that doesn't contain a "|" by using "find and replace".
  3. Replace any pipes within table cells with a code, and then substitute that code with a newline character preceded by it (indicating the start of a new row).
  4. Use the Sort module on Special:ExpandTemplates. To sort the items between the pipes and produce the desired separator, expand templates and add {{#invoke:Sort|f||- | (with the newline) before and }} after the wikitext.
  5. Delete the items that begin with "-" and a newline.
  6. Change the temporary codes for the cell separators and pipes inside the cells to restore them.

This sorting method relies on the wikitext in each row, primarily sorting by the content of the first column. The second column serves as a secondary key. However, wikitext codes in the first column cells before the content can impact the order.

You can also use Snippets/Sort table on reload to automatically sort the table when it loads using JavaScript.

Persistent sort states using cookies

You can save the state of sortable tables across reloads using Snippets/Persistent sort order.

See also

Other examples:

Category:Help/fa
Category:Help/fa