{"id":20858541,"url":"https://github.com/yard1/hoi4-quicksort","last_synced_at":"2026-03-14T09:02:35.273Z","repository":{"id":101531687,"uuid":"180046303","full_name":"Yard1/HoI4-Quicksort","owner":"Yard1","description":null,"archived":false,"fork":false,"pushed_at":"2019-04-08T20:41:15.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-19T07:23:52.927Z","etag":null,"topics":["hearts-of-iron-4","hearts-of-iron-iv","heartsofiron4","modding","modding-resources","paradox-interactive","paradoxgame","quicksort"],"latest_commit_sha":null,"homepage":null,"language":null,"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/Yard1.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":"2019-04-08T01:22:45.000Z","updated_at":"2022-03-12T17:19:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"730c824e-f860-46b6-be4a-86d9982047b5","html_url":"https://github.com/Yard1/HoI4-Quicksort","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yard1%2FHoI4-Quicksort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yard1%2FHoI4-Quicksort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yard1%2FHoI4-Quicksort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yard1%2FHoI4-Quicksort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yard1","download_url":"https://codeload.github.com/Yard1/HoI4-Quicksort/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243230101,"owners_count":20257644,"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":["hearts-of-iron-4","hearts-of-iron-iv","heartsofiron4","modding","modding-resources","paradox-interactive","paradoxgame","quicksort"],"created_at":"2024-11-18T04:46:27.751Z","updated_at":"2025-12-24T09:53:08.390Z","avatar_url":"https://github.com/Yard1.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# HoI4 Quicksort\n\nThis is an implementation of an iterative randomized [quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm for HoI 4 script arrays. The algorithm allows for very fast sorting of large arrays, compared to naive algorithms such as selection or insertion sort.\n\nMeasured on my machine with Script Profiler, sorting a random 1000-element array takes 87 ms. Worst case (sorted array) requires about 270 ms (since the pivot is random, both times may fluctuate slightly). That's about 19.6 times better performance than selection sort, and 22 times better performance than insertion sort.\n\nIn order to use the quicksort scripted effect, arguments first need to be set up beforehand (saved as non-temporary variables). They are:\narr = array to sort\nlow = starting index (you probably want 0)\nhigh = ending index (you probably want arr^num - 1)\nExample:\n```\n    # arr set up beforehand\n    # Set arguments\n    set_variable = { high = arr^num }\n    subtract_from_variable = { high = 1 }\n\n    set_variable = { low = 0 }\n\n    # Arguments: arr, high, low\n    quicksort = yes    # arr set up beforehand\n```\n\nIncluded in the file are: the quicksort scripted effects (`quicksort` and `quicksort_partition`), selection sort (`naive_sorting`), insertion sort (`insertion_sort`), scripted effect to measure performance (`sorting_test` - call it with an event while running the profiler), scripted effects to test the sorting effects and an effect to create the test array (\n`set_up_array`).\n\nFeel free to use in your mods, but give credits to Yard1 (both in code, with comments; and on your download page).\n\nMy [Ledger](https://github.com/Yard1/HoI4-Ledger) mod makes use of this algorithm, albeit in a modified version.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyard1%2Fhoi4-quicksort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyard1%2Fhoi4-quicksort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyard1%2Fhoi4-quicksort/lists"}