stable sorting
🔀 Sort settings
💡 Instructions for use
- Column numbers are counted from left to right in the data, and the first column is one, which is consistent with the column order in the spreadsheet software.
- Text comparison is arranged in character order, and Chinese is in encoding order, so it is more suitable for names and numbers; numerical comparison will be parsed into numbers first and then compared.
- After setting the second sort key, rows with the same value in the first column will be sorted according to the rules of the second column, and the result will be more in line with daily habits.
- When the header is fixed, the first row does not participate in sorting and the position remains unchanged; if the first row is data, please switch this option to Unfixed.
- The sorting is a stable sorting, and rows with identical values maintain their original order without disturbing their relative positions.
- The data is only processed in the browser and is not uploaded or saved; if you need to keep the file, please copy or download the results.
Rows with the same value are not swapped, and the result is the same every time.
What does stable mean?
Rows with the same sort key value maintain the original order.
They will not change their positions due to sorting.
benefits
The same data is sorted repeatedly, and the results are always consistent.
It is easy to compare row by row with the data before sorting.
Relationship with multiple keys
When sorting by only one column, the order of identical rows remains predictable.
If you want to further control the order, you can add a second sort key.
easy to confuse
Stability does not mean that all rows do not move, but that rows with the same value do not change randomly.
Rows with different values will of course be moved to new locations according to rules.
Result check
Look at the relative positions of rows with the same value before and after sorting.
When you need to keep files, it is most secure to add a column of original serial numbers.
If you need to keep files, add a column of original serial numbers first; stable sorting only ensures that rows with the same value are not randomly transposed.
📖 Glossary
- sort key
- The column according to which the sorting is based can be a single column or a combination of multiple columns arranged according to priority.
- Ascending and descending order
- Ascending order is from small to large or forward in character order, while descending order is the opposite. The results of the two directions for the same set of data are completely reversed.
- stable sorting
- Rows with the same sort key value maintain their original order and will not be swapped due to sorting.
- numerical comparison
- First parse the cell content into numbers and then compare the sizes to avoid misordering when comparing by characters.
- text comparison
- Compare one by one in character encoding order. Chinese characters are usually arranged in encoding order, which is suitable for names and numbers.
- multi-level sorting
- Sort by the first column first, then sort by the second column if the values are the same, and so on to form a hierarchical order.
- Header
- The field names in the first row of the table should be fixed in the first row when sorting to avoid being treated as data for comparison.
- Group sorting
- First sort by a certain column within the group, and then decide the order of the groups. It is often used to organize lists by department or region.
- Null value handling
- The arrangement position of the cell when it is empty. When comparing numerical values, space-time values are usually sorted at the end, making it easier to see valuable data first.
- delimiter
- Characters used to separate columns, tabs used for content copied by spreadsheet software, and commas used for comma-delimited files.
🔗 All keywords and tutorials
❓ FAQ
- Will stable sorting make the results unchanged?
- The relative positions of rows with the same value remain unchanged, and rows with different values move as usual.
- Why is it recommended to add the original serial number?
- Once rearranged, the sequence number is the only basis for restoring the original order.