Ajuda: Tabelas ordenáveis
| Nota: Quando modificais esta página, estais a aceitar que a vossa contribuição se publique no marco de CC0. Olhem Páginas de ajuda de domínio público para mais informação. |
Para criar uma tabela ordenável, adicione a classe sortable a uma tabela.
This class adds arrows displayed beside the header within each header cell.
(Veja o exemplo em baixo.)
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.
Modos de ordenação
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.
Datas
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).
Números
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.
Texto
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):
| ! | " | # | $ | % | & | ' | ( | ) | * | + | , | - | . | / | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | : | ; | < | = | > | ? | @ | A | B | C | |
| D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | [ | \ | ] | ^ | _ | ` | a | b | c | d | e | f | g |
| h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z | { | | | } | ~ | ¡ | ¢ | £ | ¤ | ¥ | ¦ | § | ¨ | © | ª | « | ¬ | |
|
® | ¯ | ° | ± | ² | ³ | ´ | µ | ¶ | · | ¸ | ¹ | º | » | ¼ | ½ | ¾ | ¿ | À | Á | Â | Ã | Ä | Å | Æ | Ç | È | É | Ê | Ë | Ì | Í | Î | Ï | Ð |
| Ñ | Ò | Ó | Ô | Õ | Ö | × | Ø | Ù | Ú | Û | Ü | Ý | Þ | ß | à | á | â | ã | ä | å | æ | ç | è | é | ê | ë | ì | í | î | ï | ð | ñ | ò | ó | ô |
| õ | ö | ÷ | ø | ù | ú | û | ü | ý | þ | ÿ | Ā | ā | Ă | ă | Ą | ą | Ć | ć | Ĉ | ĉ | Ċ | ċ | Č | č | Ď | ď | Đ | đ | Ē | ē | Ĕ | ĕ | Ė | ė | Ę |
| ę | Ě | ě | Ĝ | ĝ | Ğ | ğ | Ġ | ġ | Ģ | ģ | Ĥ | ĥ | Ħ | ħ | Ĩ | ĩ | Ī | ī | Ĭ | ĭ | Į | į | İ | ı | IJ | ij | Ĵ | ĵ | Ķ | ķ | ĸ | Ĺ | ĺ | Ļ | ļ |
| Ľ | ľ | Ŀ | ŀ | Ł | ł | Ń | ń | Ņ | ņ | Ň | ň | ʼn | Ŋ | ŋ | Ō | ō | Ŏ | ŏ | Ő | ő | Œ | œ | Ŕ | ŕ | Ŗ | ŗ | Ř | ř | Ś | ś | Ŝ | ŝ | Ş | ş | Š |
| š | Ţ | ţ | Ť | ť | Ŧ | ŧ | Ũ | ũ | Ū | ū | Ŭ | ŭ | Ů | ů | Ű | ű | Ų | ų | Ŵ | ŵ | Ŷ | ŷ | Ÿ | Ź | ź | Ż | ż | Ž | ž | ſ | Ə | ƒ | Ǻ | ǻ | Ǽ |
| ǽ | Ǿ | ǿ | Ș | ș | Ț | ț | ə | ˆ | ˇ | ˉ | ˘ | ˙ | ˚ | ˛ | ˜ | ˝ | ΄ | ΅ | Ά | · | Έ | Ή | Ί | Ό | Ύ | Ώ | ΐ | Α | Β | Γ | Δ | Ε | Ζ | Η | Θ |
| Ι | Κ | Λ | Μ | Ν | Ξ | Ο | Π | Ρ | Σ | Τ | Υ | Φ | Χ | Ψ | Ω | Ϊ | Ϋ | ά | έ | ή | ί | ΰ | α | β | γ | δ | ε | ζ | η | θ | ι | κ | λ | μ | ν |
| ξ | ο | π | ρ | ς | σ | τ | υ | φ | χ | ψ | ω | ϊ | ϋ | ό | ύ | ώ | Ѐ | Ё | Ђ | Ѓ | Є | Ѕ | І | Ї | Ј | Љ | Њ | Ћ | Ќ | Ѝ | Ў | Џ | А | Б | В |
| Г | Д | Е | Ж | З | И | Й | К | Л | М | Н | О | П | Р | С | Т | У | Ф | Х | Ц | Ч | Ш | Щ | Ъ | Ы | Ь | Э | Ю | Я | а | б | в | г | д | е | ж |
| з | и | й | к | л | м | н | о | п | р | с | т | у | ф | х | ц | ч | ш | щ | ъ | ы | ь | э | ю | я | ѐ | ё | ђ | ѓ | є | ѕ | і | ї | ј | љ | њ |
| ћ | ќ | ѝ | ў | џ | Ґ | ґ | Ḃ | ḃ | Ḋ | ḋ | Ḟ | ḟ | Ṁ | ṁ | Ṗ | ṗ | Ṡ | ṡ | Ṫ | ṫ | Ẁ | ẁ | Ẃ | ẃ | Ẅ | ẅ | Ỳ | ỳ | – | — | ― | ‗ | ‘ | ’ | ‚ |
| ‛ | “ | ” | „ | † | ‡ | • | … | ‰ | ′ | ″ | ‹ | › | ‼ | ‾ | ⁄ | ⁿ | ₣ | ₤ | ₧ | € | ℅ | ℓ | № | ™ | Ω | ℮ | ⅛ | ⅜ | ⅝ | ⅞ | ← | ↑ | → | ↓ | ↔ |
| ↕ | ↨ | ∂ | ∆ | ∏ | ∑ | − | ∕ | ∙ | √ | ∞ | ∟ | ∩ | ∫ | ≈ | ≠ | ≡ | ≤ | ≥ | ⌂ | ⌐ | ⌠ | ⌡ | ─ | │ | ┌ | ┐ | └ | ┘ | ├ | ┤ | ┬ | ┴ | ┼ | ═ | ║ |
| ╒ | ╓ | ╔ | ╕ | ╖ | ╗ | ╘ | ╙ | ╚ | ╛ | ╜ | ╝ | ╞ | ╟ | ╠ | ╡ | ╢ | ╣ | ╤ | ╥ | ╦ | ╧ | ╨ | ╩ | ╪ | ╫ | ╬ | ▀ | ▄ | █ | ▌ | ▐ | ░ | ▒ | ▓ | ■ |
| □ | ▪ | ▫ | ▬ | ▲ | ► | ▼ | ◄ | ◊ | ○ | ● | ◘ | ◙ | ◦ | ☺ | ☻ | ☼ | ♀ | ♂ | ♠ | ♣ | ♥ | ♦ | ♪ | ♫ | | | fi | fl | � |
Forçar o modo de ordenação de uma coluna
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
Por exemplo:
Texto wiki
{|class="wikitable sortable"
!data-sort-type="date"| Data !! Nome !! Altura !!data-sort-type="number"| Salário
|-
| 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
|}
Renderização
| Data | Nome | Altura | Salário |
|---|---|---|---|
| 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 |
Especificar a chave de ordenação
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.
Texto wiki
{|class="wikitable sortable"
! Nome e Sobrenome !! Altura
|-
|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
|}
Renderização
| Nome e Sobrenome | Altura |
|---|---|
| John Smith | 1.85 |
| Ian Ray | 1.89 |
| Zachary Bianchi | 1.72 |
Controlar a ordenação e exibição
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[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="...".
Exemplos
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="...".
| números | data-sort-type="number"
|
data-sort-type="number"
| |
|---|---|---|---|
| -8e3 | -8 e3 | -8 e3 | |
| -3e-3 | -3 e-3 | -3 e-3 | |
| 2.000 | 2-5 km² | data-sort-value="3.5" |
2-5 km² |
| 3.99 | 3.99 km² | 3.99 km² | |
| 4 | 4 km² | 4 km² | |
| 90 % | 90 Percent | data-sort-value="90" |
about 90 Percent |
| 1E2 | 100[1] | 100[1] | |
| 1,000,000.0 | 1 000 000.0 | data-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.
|
|
|
|
|
|
Chave de ordenação secundária
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.
Por exemplo:
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.
| Números | Texto | Datas | Moeda | Mais texto |
|---|---|---|---|---|
| 4 | a | 01.Jan.2005 | 4.20 | row 1 |
| 5 | a | 05/12/2006 | 7.15 | row 2 |
| 1 | b | 02-02-2004 | 5.00 | row 3 |
| 1 | a | 02-02-2004 | 5.00 | row 4 |
| 2 | x | 13-apr-2005 | row 5 | |
| 2 | a | 13-apr-2005 | row 6 | |
| 3 | a | 17.aug.2006 | 6.50 | row 7 |
| 3 | z | 25.aug.2006 | 2.30 | row 8 |
| 3 | z | 28.aug.2006 | 5.50 | row 9 |
| 3 | z | 31.aug.2006 | 3.77 | row 10 |
| 3 | z | 01.sep.2006 | 1.50 | row 11 |
| Fim |
Funcionalidades adicionais
Excluindo a última linha da ordenação
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(!).
Texto wiki
{|class="wikitable sortable"
! Nome !! Sobrenome !! Altura
|-
| John || Smith || 1.85
|-
| Ron || Ray || 1.89
|-
| Mario || Bianchi || 1.72
|- class="sortbottom"
! !! Média: || 1.82
|}
Renderização
| Nome | Sobrenome | Altura |
|---|---|---|
| John | Smith | 1.85 |
| Ron | Ray | 1.89 |
| Mario | Bianchi | 1.72 |
| Média: | 1.82 |
Excluindo a primeira linha da ordenação
You can exclude the first row by using the class="sorttop".
Texto wiki
{|class="wikitable sortable"
! Nome !! Sobrenome !! Altura
|- class="sorttop"
! !! Média: || 1.82
|-
| John || Smith || 1.85
|-
| Ron || Ray || 1.89
|-
| Mario || Bianchi || 1.72
|}
Renderização
| Nome | Sobrenome | Altura |
|---|---|---|
| Média: | 1.82 | |
| John | Smith | 1.85 |
| Ron | Ray | 1.89 |
| Mario | Bianchi | 1.72 |
Tornar uma coluna não ordenável
To stop a column from being sortable, use class="unsortable" in its header cell's attributes.
Texto wiki
{|class="wikitable sortable"
! Números !! Alfabeto !! Datas !! Moeda !!class="unsortable"| Não ordenável
|-
| 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 !!
|-
|}
Renderização
| Números | Alfabeto | Datas | Moeda | Não ordenável |
|---|---|---|---|---|
| 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 | Original example |
Manter algumas filas juntas
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.
Texto wiki
{| class="wikitable sortable"
!style="width:9em"| País !!data-sort-type="number"| Área
|-
| França
| 674 843 km²
|- class="expand-child" style="font-size:85%; line-height:1.2; color:gray"
|colspan="2"| Em Paris na Torre Eiffel.
|-
| Reino Unido
| 242 495 km²
|- class="expand-child" style="font-size:85%; line-height:1.2; color:gray"
|colspan="2"| No Reino Unido não pode pagar com euros.
|- class="expand-child" style="font-size:85%; line-height:1.2; color:gray"
|colspan="2"| E conduz no lado esquerdo da estrada.
|-
| Alemanha
| 357 168 km²
|- class="expand-child" style="font-size:85%; line-height:1.2; color:gray"
|colspan="2"| A Alemanha inclui a antiga DDR.
|}
Renderização
| País | Área |
|---|---|
| França | 674 843 km² |
| Em Paris na Torre Eiffel. | |
| Reino Unido | 242 495 km² |
| No Reino Unido não pode pagar com euros. | |
| E conduz no lado esquerdo da estrada. | |
| Alemanha | 357 168 km² |
| A Alemanha inclui a antiga 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"
! País/província !! Capital
|-
| França || Paris
|-
| Holanda || Amesterdão
|-
|data-sort-value="Holanda"| Sul da Holanda ||data-sort-value="Amsterdão"| Haia
|-
| Reino Unido || Londres
|}
| País/província | Capital |
|---|---|
| França | Paris |
| Holanda | Amesterdão |
| Sul da Holanda | Haia |
| Reino Unido | Londres |
Datas especiais
Para representar os anos anteriores à Era Comum (BCE), subtraia o ano de BCE de 10 000. Por exemplo, -62 BCE seria 10 000 - 62 = 9938.
Por exemplo, 23 de setembro de 62 BCE seria representado como 23-09-9938.
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.
Texto wiki
{| class="wikitable sortable"
|-
! Data
|-
| 2022-01-01
|-
| 2023-12-31
|-
| 2024
|-
| 2024-04
|-
| 2024-04-00
|-
| 2024-05
|-
| 2024-05-00
|}
Renderização
| Data |
|---|
| 2022-01-01 |
| 2023-12-31 |
| 2024 |
| 2024-04 |
| 2024-04-00 |
| 2024-05 |
| 2024-05-00 |
Utilizando #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.
Por exemplo, utilizando date:
| data inserida | texto | data e hora conforme interpretadas, com chave de ordenação oculta | inserção com chave de ordenação visível | inserção com chave de ordenação ocultada | Hora Unix |
|---|---|---|---|---|---|
| 010203 | 01 dez. 2025 01:02:03 | &301764550923 010203 | 010203 | 1764550923 | |
| 1/2 | 02 jan. 2025 00:00:00 | &301735776000 1/2 | 1/2 | 1735776000 | |
| 1/2/3 | 02 jan. 2003 00:00:00 | &301041465600 1/2/3 | 1/2/3 | 1041465600 | |
| 1-2-2003 | 01 fev. 2003 00:00:00 | &301044057600 1-2-2003 | 1-2-2003 | 1044057600 | |
| 1-2-3 | 03 fev. 2001 00:00:00 | &300981158400 1-2-3 | 1-2-3 | 981158400 | |
| 2007 | 01 jan. 2007 00:00:00 | &301167609600 2007 | 2007 | 1167609600 | |
| 1 Jan 111, 00:00:00 | 01 jan. 0111 00:00:00 | &241335609600 1 Jan 111, 00:00:00 | 1 Jan 111, 00:00:00 | -58664390400 | |
| 31 Dec 9999, 23:59:59 | 31 dez. 9999 23:59:59 | &553402300799 31 Dec 9999, 23:59:59 | 31 Dec 9999, 23:59:59 | 253402300799 | |
| Sep 1970 | 01 set. 1970 00:00:00 | &300020995200 Sep 1970 | Sep 1970 | 20995200 | |
| 1970 | 01 jan. 1970 00:00:00 | &300000000000 1970 | 1970 | 0 | |
| Jun 2007 | or later | 01 jun. 2007 00:00:00 or later | &301180656000 Jun 2007 or later | Jun 2007 or later | 1180656000 or later |
| Jun 2007 | perhaps earlier | 01 jun. 2007 00:00:00 perhaps earlier | &301180656000 Jun 2007 perhaps earlier | Jun 2007 perhaps earlier | 1180656000 perhaps earlier |
| 2007-6 | 01 jun. 2007 00:00:00 | &301180656000 2007-6 | 2007-6 | 1180656000 | |
| Jun 2007 | 01 jun. 2007 00:00:00 | &301180656000 Jun 2007 | Jun 2007 | 1180656000 | |
| 4 Jun 2007 | 04 jun. 2007 00:00:00 | &301180915200 4 Jun 2007 | 4 Jun 2007 | 1180915200 | |
| 3 Jul 2007 | 03 jul. 2007 00:00:00 | &301183420800 3 Jul 2007 | 3 Jul 2007 | 1183420800 | |
| 12 Aug 2006 | 12 ago. 2006 00:00:00 | &301155340800 12 Aug 2006 | 12 Aug 2006 | 1155340800 | |
| 1 Mar 2006 -1day | 28 fev. 2006 00:00:00 | &301141084800 1 Mar 2006 -1day | 1 Mar 2006 -1day | 1141084800 | |
| 1 Mar 2008 -1day | 29 fev. 2008 00:00:00 | &301204243200 1 Mar 2008 -1day | 1 Mar 2008 -1day | 1204243200 | |
| 1 Mar 2010 -1day | 28 fev. 2010 00:00:00 | &301267315200 1 Mar 2010 -1day | 1 Mar 2010 -1day | 1267315200 | |
| 1 Mar 1900 -1day | 28 fev. 1900 00:00:00 | &297796022400 1 Mar 1900 -1day | 1 Mar 1900 -1day | -2203977600 | |
| 1 Mar 1600 -1day | 29 fev. 1600 00:00:00 | &288329001600 1 Mar 1600 -1day | 1 Mar 1600 -1day | -11670998400 | |
| Jun 1607 | 01 jun. 1607 00:00:00 | &288557875200 Jun 1607 | Jun 1607 | -11442124800 | |
| 20251201085216 | 01 dez. 2025 08:52:16 | &301764579136 20251201085216 | 20251201085216 | 1764579136 | |
| yesterday | 30 nov. 2025 00:00:00 | &301764460800 yesterday | yesterday | 1764460800 | |
| today | 01 dez. 2025 00:00:00 | &301764547200 today | today | 1764547200 | |
| tomorrow | 02 dez. 2025 00:00:00 | &301764633600 tomorrow | tomorrow | 1764633600 | |
| 1week | 08 dez. 2025 08:52:16 | &301765183936 1week | 1week | 1765183936 | |
| -1week | 24 nov. 2025 08:52:16 | &301763974336 -1week | -1week | 1763974336 | |
| 1day | 02 dez. 2025 08:52:16 | &301764665536 1day | 1day | 1764665536 | |
| -1day | 30 nov. 2025 08:52:16 | &301764492736 -1day | -1day | 1764492736 | |
| 1month | 01 jan. 2026 08:52:16 | &301767257536 1month | 1month | 1767257536 | |
| -1month | 01 nov. 2025 08:52:16 | &301761987136 -1month | -1month | 1761987136 | |
| 1year | 01 dez. 2026 08:52:16 | &301796115136 1year | 1year | 1796115136 | |
| -1year | 01 dez. 2024 08:52:16 | &301733043136 -1year | -1year | 1733043136 | |
| 1000year | 01 dez. 3025 08:52:16 | &333321487936 1000year | 1000year | 33321487936 | |
| 10000month | 01 abr. 2859 08:52:16 | &328061974336 10000month | 10000month | 28061974336 | |
| 1000000day | 29 out. 4763 08:52:16 | &388164579136 1000000day | 1000000day | 88164579136 | |
| 10000000hour | 18 set. 3166 00:52:16 | &337764579136 10000000hour | 10000000hour | 37764579136 | |
| 1000000000minute | 30 mar. 3927 19:32:16 | &361764579136 1000000000minute | 1000000000minute | 61764579136 | |
| 100000000000second | 16 out. 5194 18:38:56 | &401764579136 100000000000second | 100000000000second | 101764579136 | |
| 7980year | Erro: #time só suporta anos até 9999. | &Expression error: Unexpected < operator. 7980year | 7980year | Erro: #time só suporta anos até 9999. | |
| -1890year | 01 dez. 0135 08:52:16 | &242121881536 -1890year | -1890year | -57878118464 | |
| Mon | 01 dez. 2025 00:00:00 | &301764547200 Mon | Mon | 1764547200 | |
| Tue | 02 dez. 2025 00:00:00 | &301764633600 Tue | Tue | 1764633600 | |
| Wed | 03 dez. 2025 00:00:00 | &301764720000 Wed | Wed | 1764720000 | |
| Thu | 04 dez. 2025 00:00:00 | &301764806400 Thu | Thu | 1764806400 | |
| Fri | 05 dez. 2025 00:00:00 | &301764892800 Fri | Fri | 1764892800 | |
| Sat | 06 dez. 2025 00:00:00 | &301764979200 Sat | Sat | 1764979200 | |
| Sun | 07 dez. 2025 00:00:00 | &301765065600 Sun | Sun | 1765065600 | |
| Erro: Hora inválida. | &Expression error: Unexpected < operator. | Erro: Hora inválida. | |||
| unknown | Erro: Hora inválida. | &Expression error: Unexpected < operator. unknown | unknown | Erro: Hora inválida. |
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.
Consulte também:
- w:Template:dts - Sorting a table by a date column
Célula que abrange várias linhas/células
A cell that extends across multiple rows or columns is considered equivalent to having multiple cells with identical values.
|
| ||||||||||||||||||||||||||
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.
Por exemplo:
| País | Capital |
|---|---|
| França | Paris |
| Reino Unido | Londres |
Coluna estática
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.
|
|
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.
Ordem predefinida
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:
- Rearrange the table's wikitext without the top and bottom lines.
- Replace the cell separators with a unique code that doesn't contain a "|" by using "find and replace".
- 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).
- 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. - Delete the items that begin with "-" and a newline.
- 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.
Consultar também
- Help:Table
- Categoria: Modelos de ordenação
- jquery.tablesorter.js – TableSorter para MediaWiki
- http://www.kryogenix.org/code/browser/sorttable/ – Stuart Langridge's original code needs explaining. In the MediaWiki version, tables no longer need IDs.
- For much more detailed instructions, see the Wikipedia page.
- Manual:$wgCategoryCollation – Allows you to change the collation used for categories (requires shell access).
- Unicode character references on the Wikibooks.
Outros exemplos:
- w:Ranked list of Dutch provinces
- w:List of countries by GDP estimates for 2006 (nominal)
- w:List of countries by GDP (PPP), 2006
- w:List of longest reigning current monarchs – Date columns can be sorted by those who don't care about date format and by those who prefer [[YYYY-MM-DD]].
- Pokémon table – Place a "#" before numbers to position them ahead of "-".
- Nuclear power by country (Lista em Destaque)
- w:Desert Island Discs: castaways' choices
- zh:秘鲁行政区划 (Subdivisões do Peru) para ordenação em chinês (CJK)
- w:Standard electrode potential (data page)