{"id":23973207,"url":"https://github.com/simonwei97/gitbook-algo","last_synced_at":"2026-02-25T22:04:26.098Z","repository":{"id":210550170,"uuid":"726840230","full_name":"simonwei97/GitBook-algo","owner":"simonwei97","description":null,"archived":false,"fork":false,"pushed_at":"2023-12-03T15:41:47.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-24T15:51:11.897Z","etag":null,"topics":[],"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/simonwei97.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}},"created_at":"2023-12-03T15:01:51.000Z","updated_at":"2023-12-03T15:01:52.000Z","dependencies_parsed_at":"2023-12-03T16:22:14.533Z","dependency_job_id":"4384d101-90a3-458d-8f62-a9f7565b4278","html_url":"https://github.com/simonwei97/GitBook-algo","commit_stats":null,"previous_names":["simonwei97/gitbook-algo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/simonwei97/GitBook-algo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonwei97%2FGitBook-algo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonwei97%2FGitBook-algo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonwei97%2FGitBook-algo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonwei97%2FGitBook-algo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonwei97","download_url":"https://codeload.github.com/simonwei97/GitBook-algo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonwei97%2FGitBook-algo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29842886,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T21:18:31.832Z","status":"ssl_error","status_checked_at":"2026-02-25T21:18:29.265Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2025-01-07T04:17:33.327Z","updated_at":"2026-02-25T22:04:26.082Z","avatar_url":"https://github.com/simonwei97.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"---\ndescription: 常考排序\n---\n\n# 排序算法\n\n### 快速排序\n\n```go\nfunc QuickSort(nums []int) []int {\n    // 思路：把一个数组分为左右两段，左段小于右段\n    quickSort(nums, 0, len(nums)-1)\n    return nums\n\n}\n// 原地交换，所以传入交换索引\nfunc quickSort(nums []int, start, end int) {\n    if start \u003c end {\n        // 分治法：divide\n        pivot := partition(nums, start, end)\n        quickSort(nums, 0, pivot-1)\n        quickSort(nums, pivot+1, end)\n    }\n}\n// 分区\nfunc partition(nums []int, start, end int) int {\n    // 选取最后一个元素作为基准pivot\n    p := nums[end]\n    i := start\n    // 最后一个值就是基准所以不用比较\n    for j := start; j \u003c end; j++ {\n        if nums[j] \u003c p {\n            swap(nums, i, j)\n            i++\n        }\n    }\n    // 把基准值换到中间\n    swap(nums, i, end)\n    return i\n}\n// 交换两个元素\nfunc swap(nums []int, i, j int) {\n    t := nums[i]\n    nums[i] = nums[j]\n    nums[j] = t\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonwei97%2Fgitbook-algo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonwei97%2Fgitbook-algo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonwei97%2Fgitbook-algo/lists"}