{"id":15771300,"url":"https://github.com/trstringer/sorting-algorithm-stability","last_synced_at":"2025-09-10T14:04:56.945Z","repository":{"id":147740277,"uuid":"321130749","full_name":"trstringer/sorting-algorithm-stability","owner":"trstringer","description":"Demo application highlighting sorting algorithm stability output","archived":false,"fork":false,"pushed_at":"2020-12-13T18:52:24.000Z","size":1,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"dev","last_synced_at":"2023-03-26T01:40:12.176Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trstringer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-13T18:21:05.000Z","updated_at":"2024-06-19T08:00:38.335Z","dependencies_parsed_at":"2023-06-26T11:01:03.021Z","dependency_job_id":null,"html_url":"https://github.com/trstringer/sorting-algorithm-stability","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trstringer%2Fsorting-algorithm-stability","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trstringer%2Fsorting-algorithm-stability/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trstringer%2Fsorting-algorithm-stability/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trstringer%2Fsorting-algorithm-stability/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trstringer","download_url":"https://codeload.github.com/trstringer/sorting-algorithm-stability/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246465220,"owners_count":20781919,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-04T15:01:46.328Z","updated_at":"2025-03-31T11:44:45.131Z","avatar_url":"https://github.com/trstringer.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sorting stability\n\nThis sample application highlights a situation when sorting stability is needed.\n\nThis data will be sorted twice:\n\n1. Sort by `Name`\n1. Sort by `State`\n\nIf the end result is the dataset being sorted by state and name, the first sort of `Name` does *not* require stability. This demo highlights the output though of the second sort:\n\n* If you sort with an **unstable** algorithm then you can lose the inner sorting by `Name`\n* If you sort with a **stabe** algorithmn, you preserve the inner sorting by `Name`, so the output dataset is sorted by state and name correctly\n\n## Output\n\n```text\n--- Unsorted ----\nName: Thomas, State: New Hampshire\nName: Annie, State: New Hampshire\nName: Chris, State: Maine\nName: Jackie, State: Vermont\nName: Marie, State: New Hampshire\nName: Daniel, State: Maine\nName: Vivian, State: Maine\nName: Michelle, State: Maine\n\n--- Sorted by Name (heap sort: unstable) ----\nName: Annie, State: New Hampshire\nName: Chris, State: Maine\nName: Daniel, State: Maine\nName: Jackie, State: Vermont\nName: Marie, State: New Hampshire\nName: Michelle, State: Maine\nName: Thomas, State: New Hampshire\nName: Vivian, State: Maine\n\n--- Sorted by State (heap sort: unstable) ----\nName: Daniel, State: Maine\nName: Michelle, State: Maine\nName: Chris, State: Maine\nName: Vivian, State: Maine\nName: Thomas, State: New Hampshire\nName: Marie, State: New Hampshire\nName: Annie, State: New Hampshire\nName: Jackie, State: Vermont\n\n************************************\nNow trying with a stable sort on state\n************************************\n\n--- Unsorted ----\nName: Thomas, State: New Hampshire\nName: Annie, State: New Hampshire\nName: Chris, State: Maine\nName: Jackie, State: Vermont\nName: Marie, State: New Hampshire\nName: Daniel, State: Maine\nName: Vivian, State: Maine\nName: Michelle, State: Maine\n\n--- Sorted by Name (heap sort: unstable) ----\nName: Annie, State: New Hampshire\nName: Chris, State: Maine\nName: Daniel, State: Maine\nName: Jackie, State: Vermont\nName: Marie, State: New Hampshire\nName: Michelle, State: Maine\nName: Thomas, State: New Hampshire\nName: Vivian, State: Maine\n\n--- Sorted by State (merge sort: stable) ----\nName: Chris, State: Maine\nName: Daniel, State: Maine\nName: Michelle, State: Maine\nName: Vivian, State: Maine\nName: Annie, State: New Hampshire\nName: Marie, State: New Hampshire\nName: Thomas, State: New Hampshire\nName: Jackie, State: Vermont\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrstringer%2Fsorting-algorithm-stability","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrstringer%2Fsorting-algorithm-stability","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrstringer%2Fsorting-algorithm-stability/lists"}