User:Lent/sandbox
From Wikipedia, the free encyclopedia
Max Annenberg
Max Annenberg, son of Moses Annenberg, brother of Walter Anneberg
Biographic sketch:[1]
1925 Relocation to New York. [2]
On December 7, 1941, before the news of the bombing of Pearl Harbor was made public, a public address message for Max Annenberg's chauffeur to report, has followed the message for Col. William J. Donovan to call his office immediately, with the third and final message being for military personnel to report to their bases.[3][4]
Introduction to interactive example
Only some of the many sorting algorithms currently developed are known as stable. The quality that makes these algorithms stable is that when sorting on a row in a table, if the value in the column chosen to be the sort "key" is identical to another row's value in that same "key" column, the algorithm will leave the relative order of those rows unchanged. The notable sorting algorithm, Quicksort, is usually implemented lacking stability.
Mobile Browsers vs. Sortable tables
Wikipedia supports sortable tables in desktop browsers, including stable sorting by using the Shift key while clicking on the second column to be sorted. Sadly, as of February 2020, sortable Wikipedia tables only work with desktop browsers. Even mobile browsers set to "View Desktop Site/Desktop Page" mode fail to work with Javascript code which provides Wikipedia's sortable columns. Originally, mobile browsers had extremely limited hardware resources, making a full-feature browser impossible.[5] While innovative solutions such as the Wireless Application Protocol allowed more of the web to be browsed, the results were extremely varied. As mobile devices grew in power, and browser capabilities continued to grow, Wikipedia's developers and users returned to the problem, keeping in consideration extremely limited mobile devices still in widespread use around the world.[6]
Icons buttons found on Column Headers
The browser currently displaying this page is capable of sorting tables, the preceding icon buttons should be on each column header. If not, interactive sorting for will not work, so "No soup for you!". If the following tables show no icons in the column headers, your browser is cannot performing sorting at this time.
Stable sort by State then City
The following example has fifteen cities in seven different states.
Each state is abbreviated using the 2-letter codes used by the United States Postal Service.
Rationale for Postal Codes
After suffering from duplicate city names within the U.S., the Post Office made an effort to keep new duplicate names from occurring:
To help address this problem, in the 1880s the instructions on selecting new Post Office names went [...]:
Select a short name for the proposed office, which, when written, will not resemble the name of any other post office in the United States.
— What's in a (Post Office) Name? : From Aaronsburg, Pennsylvania, to Zwolle, Louisiana, [7]
This was found to be too restrictive, and the Post Office removed the word United.:
In the 1890s this was relaxed:
Select a short name for the proposed office, which, when written, will not resemble the name of any other post office in the State.
— What's in a (Post Office) Name? : From Aaronsburg, Pennsylvania, to Zwolle, Louisiana, [7]
The Postal zone introduced in 1943 helped route mail within large U.S. cities, and 1963's introduction of the ZIP Code helped improved delivery of mail to cities with the same name by first directing the mail to the correct region of the country. Standardization of the two—letter code for each state, territory and the capital district also made mail sorting easier.[8]
Example
Two stable sorts are performed on the randomly ordered, original table.
Note that only the second sort is required to be stable to get our desired result of a list which is alphabetical first by two—letter State code, then for each City within the alphabetically ordered State.
Mobile sorting workarounds
While not possible on most mobile browsers, sorting can be achieve through these workarounds:
- Obtain a browser which wil support a Desktop site and the Javascript needed:
- Use a keyboard which supports a TAB key:
- Bluetooth keyboard
- USB keyboard via a USB On-The-Go cable
- Virtual board which supports the TAB key , setting the keyboard visible, even when not on an input field
- Load the sortable page and verify that the column's sorting triangles are on the column titles
- Sort the selected primary column via:
- Clicking on the column header to toggle trough ascending or descending sorting
- Pressing TAB key on the keyboard, to move to the column, then pressing the Enter key.
- Press the TAB key or Shift and TAB key to position at the second sorting column and press Shift and Enter together.
- Now go and Square the Circle.
Table
| Row | City | State | |
|---|---|---|---|
| 1 | Chicago | IL | |
| 2 | Rockford | IL | |
| 3 | Evanston | IL | |
| 4 | Champaign | IL | |
| 5 | Detroit | MI | |
| 6 | New York | NY | |
| 7 | Buffalo | NY | |
| 8 | Milwaukee | WI | |
| 9 | Albany | NY | |
| 10 | Green Bay | WI | |
| 11 | Syracuse | NY | |
| 12 | Rockford | MI | |
| 13 | Rockford | IA | |
| 14 | Rockford | TN | |
| 15 | Rockford | MN |
| Old vs. New Row | City | State |
|---|---|---|
| 13 → 1 | Rockford | IA |
| 2 → 2 | Rockford | IL |
| 3 → 3 | Evanston | IL |
| 1 → 4 | Chicago | IL |
| 4 → 5 | Champaign | IL |
| 12 → 6 | Rockford | MI |
| 5 → 7 | Detroit | MI |
| 15 → 8 | Rockford | MN |
| 11 → 9 | Syracuse | NY |
| 6 → 10 | New York | NY |
| 7 → 11 | Buffalo | NY |
| 9 → 12 | Albany | NY |
| 14 → 13 | Rockford | TN |
| 8 → 14 | Milwaukee | WI |
| 10 → 15 | Green Bay | WI |
| Original vs. Sort then Another stable sort | City | State |
|---|---|---|
| 13 → 1 → 1 | Rockford | IA |
| 4 → 5 → 2 | Champaign | IL |
| 1 → 4 → 3 | Chicago | IL |
| 3 → 3 → 4 | Evanston | IL |
| 2 → 2 → 5 | Rockford | IL |
| 5 → 7 → 6 | Detroit | MI |
| 12 → 6 → 7 | Rockford | MI |
| 15 → 8 → 8 | Rockford | MN |
| 9 → 12 → 9 | Albany | NY |
| 7 → 11 → 10 | Buffalo | NY |
| 6 → 10 → 11 | New York | NY |
| 11 → 9 → 12 | Syracuse | NY |
| 14 → 13 → 13 | Rockford | TN |
| 10 → 15 → 14 | Green Bay | WI |
| 8 → 14 → 15 | Milwaukee | WI |
Note that only the second sort is required to be stable to get our
desired result, as once the rows are ordered by State, the cities can be in
any order for the current State'. The second sort is required to be stable to keep the states in order, while alphabetizing the cities within the state.
Stable sort by City then State
In this case, when we sort by alphabetically by City, we almost have the list
we want. The problem is that there are many rows with the city of Rockford. These cities are properly between
New York, NY
and
Syracuse, NY, but the
States for the cities of Rockford remain in their original, non-alphabetic
order. With a second stable sort, we can sort our file, leaving all the
unique cities in their place and taking the cities with equal names, that is
the cities of Rockford, and putting them in alphabetic order by the
codes of each one's two—letter State code.
| Row | City | State | |
|---|---|---|---|
| 1 | Chicago | IL | |
| 2 | Rockford | IL | |
| 3 | Evanston | IL | |
| 4 | Champaign | IL | |
| 5 | Detroit | MI | |
| 6 | New York | NY | |
| 7 | Buffalo | NY | |
| 8 | Milwaukee | WI | |
| 9 | Albany | NY | |
| 10 | Green Bay | WI | |
| 11 | Syracuse | NY | |
| 12 | Rockford | MI | |
| 13 | Rockford | IA | |
| 14 | Rockford | TN | |
| 15 | Rockford | MN |
| Row↘↓→ Source Current | City | State |
|---|---|---|
| 9 → 1 | Albany | NY |
| 7 → 2 | Buffalo | NY |
| 4 → 3 | Champaign | IL |
| 1 → 4 | Chicago | IL |
| 5 → 5 | Detroit | MI |
| 3 → 6 | Evanston | IL |
| 10 → 7 | Green Bay | WI |
| 8 → 8 | Milwaukee | WI |
| 6 → 9 | New York | NY |
| 12 → 10 | Rockford | MI |
| 13 → 11 | Rockford | IA |
| 14 → 12 | Rockford | TN |
| 15 → 13 | Rockford | MN |
| 2 → 14 | Rockford | IL |
| 11 → 15 | Syracuse | NY |
| Original vs. Sort then Another stable sort | City | State |
|---|---|---|
| 9 → 1 → 1 | Albany | NY |
| 7 → 2 → 2 | Buffalo | NY |
| 4 → 3 → 3 | Champaign | IL |
| 1 → 4 → 4 | Chicago | IL |
| 5 → 5 → 5 | Detroit | MI |
| 3 → 6 → 6 | Evanston | IL |
| 10 → 7 → 7 | Green Bay | WI |
| 8 → 8 → 8 | Milwaukee | WI |
| 6 → 9 → 9 | New York | NY |
| 13 → 11 → 10 | Rockford | IA |
| 2 → 14 → 11 | Rockford | IL |
| 12 → 10 → 12 | Rockford | MI |
| 15 → 13 → 13 | Rockford | MN |
| 14 → 12 → 14 | Rockford | TN |
| 11 → 15 → 15 | Syracuse | NY |
Derived from Jeffery S. Leon's Sorting Algorithms — Stability". [10]
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.


