-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
huanghongkai
committed
Jun 26, 2023
1 parent
82b543f
commit 37d9d04
Showing
7 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
_sort := func(arr, left, right, less) { | ||
if right-left <= 0 { | ||
return arr | ||
} | ||
i := left | ||
|
||
for j := left; j < right; j++ { | ||
if less(j, right) { | ||
if i != j { | ||
tmp := arr[i] | ||
arr[i] = arr[j] | ||
arr[j] = tmp | ||
} | ||
i++ | ||
} | ||
} | ||
|
||
if i != right { | ||
tmp := arr[i] | ||
arr[i] = arr[right] | ||
arr[right] = tmp | ||
} | ||
|
||
_sort(arr, left, i-1, less) | ||
_sort(arr, i+1, right, less) | ||
return arr | ||
} | ||
|
||
export { | ||
sort: func(arr, less) { | ||
return _sort(arr, 0, len(arr)-1, less) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters