Talk:Sorting algorithm: Difference between revisions

Content deleted Content added
Advice, comments request on How is this stable sort example?"
Line 827:
 
--[[User:Lent|Lent]] ([[User talk:Lent|talk]]) 08:55, 26 February 2020 (UTC)
 
==How is this stable sort example?==
===Stable sorting example===
{| class="wikitable sortable mw-collapsible mw-collapsed" style="display: inline-table;"
|+ {{nowrap|Unsorted table}}
! scope="col" | City
! scope="col" | State
|-
| Chicago || IL
|-
| {{font color|blue|Rockford}} || {{font color|blue|IL}}
|-
| Evanston || IL
|-
| Champaign || IL
|-
| Detroit || MI
|-
| {{font color|green|New York}} || {{font color|green|NY}}
|-
| Buffalo || NY
|-
| Milwaukee || WI
|-
| Albany || NY
|-
| Green Bay || WI
|-
| {{font color|brown|Syracuse}} || {{font color|brown|NY}}
|-
| {{font color|violet|Rockford}} || {{font color|violet|MI}}
|-
| {{font color|red|Rockford}} || {{font color|red|IA}}
|-
|Rockford ||TN
|-
|Rockford ||MN
|}
 
{|| class="wikitable sortable mw-collapsible mw-collapsed" style="display: inline-table;"
|+ Sorted Alphabetically by only City
!'''City'''!!'''States'''
|-
|Albany || NY
|-
|Buffalo || NY
|-
|Champaign || IL
|-
|Chicago || IL
|-
|Detroit || MI
|-
|Evanston || IL
|-
|Green Bay || WI
|-
|Milwaukee || WI
|-
| {{font color|green|New York}} || {{font color|green|NY}}
|-
| {{font color|violet|Rockford}} || {{font color|violet|MI}}
|-
| {{font color|red|Rockford}} || {{font color|red|IA}}
|-
|Rockford || TN
|-
|Rockford || MN
|-
| {{font color|blue|Rockford}} || {{font color|blue|IL}}
|-
| {{font color|brown|Syracuse}} || {{font color|brown|NY}}
|}
 
{|| class="wikitable sortable mw-collapsible mw-collapsed" style="display: inline-table;"
|+ Sorted Alphabetically by only State
!'''City'''!!'''States'''
|-
| {{font color|red|Rockford}} || {{font color|red|IA}}
|-
| {{font color|blue|Rockford}} || {{font color|blue|IL}}
|-
| Evanston || IL
|-
| Chicago || IL
|-
| Champaign || IL
|-
| {{font color|violet|Rockford}} || {{font color|violet|MI}}
|-
| Detroit || MI
|-
| Rockford || MN
|-
| {{font color|brown|Syracuse}} || {{font color|brown|NY}}
|-
| {{font color|green|New York}} || {{font color|green|NY}}
|-
| Buffalo || NY
|-
| Albany || NY
|-
| Rockford || TN
|-
| Milwaukee || WI
|-
| Green Bay || WI
|}
 
{|| class="wikitable sortable mw-collapsible mw-collapsed" style="display: inline-table;"
! '''City'''!! '''States'''
|+ Sorted Alphabetically by State, then City
|-
| {{font color|red|Rockford}} || {{font color|red|IA}}
|-
| Champaign || IL
|-
| Chicago || IL
|-
| Evanston || IL
|-
| {{font color|blue|Rockford}} || {{font color|blue|IL}}
|-
| Detroit || MI
|-
| {{font color|violet|Rockford}} || {{font color|violet|MI}}
|-
| Rockford || MN
|-
| Albany || NY
|-
| Buffalo || NY
|-
| {{font color|green|New York}} || {{font color|green|NY}}
|-
| {{font color|brown|Syracuse}} || {{font color|brown|NY}}
|-
| Rockford || TN
|-
| Green Bay || WI
|-
| Milwaukee || WI
|}
 
{|| class="wikitable sortable mw-collapsible mw-collapsed" style="display: inline-table;"
! '''City'''!! '''States'''
|+ Sorted Alphabetically by City, then State
 
|-
| Albany || NY
|-
| Buffalo || NY
|-
| Champaign || IL
|-
| Chicago || IL
|-
| Detroit || MI
|-
| Evanston || IL
|-
| Green Bay || WI
|-
| Milwaukee || WI
|-
| {{font color|green|New York}} || {{font color|green|NY}}
|-
| {{font color|red|Rockford}} || {{font color|red|IA}}
|-
| {{font color|blue|Rockford}} || {{font color|blue|IL}}
|-
| {{font color|violet|Rockford}} || {{font color|violet|MI}}
|-
| Rockford || MN
|-
| Rockford || TN
|-
| {{font color|brown|Syracuse}} || {{font color|brown|NY}}
|}
<small>Derived from Jeffery S. Leon's ''Sorting Algorithms — Stability".'' <ref>{{Cite web|url=http://homepages.math.uic.edu/~leon/cs-mcs401-s08/handouts/stability.pdf|title=Sorting Algorithms — Stability|last=Leon|first=Jeffrey S.|date=13 January 2008|website=Department of Mathematics, Statistics, and Computer Science {{!}} University of Illinois at Chicago|url-status=live|archive-url=https://web.archive.org/web/20141127125921/http://homepages.math.uic.edu/~leon/cs-mcs401-s08/handouts/stability.pdf|archive-date=27 November 2014|access-date=28 February 2020|quote=Our sorting software might allow sorting on only <b>one field at a time</b>. We may 1) First sort the array <i>A</i> alphabetically by <b>city</b>. 2) Then sort the array <i>A</i> alphabetically by <b>state</b>, using a stable sorting algorithm.}}</ref></small>
 
To sort by the above tables, click on the triangle. Then hold the [[Shift key]] and click on the triangle to sort by another column, while keeping the order for the first column when values of the second column are equal.
 
=== Criticisms, Suggestions and Comments ===
 
I need some advice on [[Wikipedia:Manual_of_Style/Accessibility/Data_tables_tutorial#Summary|MOS Table Summaries]], [[Wikipedia:Manual_of_Style/Accessibility/Data_tables_tutorial#Color|Table Color]] (used to emphasize motion of rows during sorting), and the five across tables.
 
Also which, if any data elements, should I get rid of? I think omitting a few more cities named Rockford might help, right?
 
Anyway, I would like this to be a nice example, which allows interaction using the built-in Wikipedia functionality for sortable tables.
 
Finally, where can I find documentation for normal users that the holding [[Shift key]] while clicking a sort triangle maintains the previous column(s) sort order? Did you know about this?
 
--[[User:Lent|Lent]] ([[User talk:Lent|talk]]) 06:13, 28 February 2020 (UTC)