Skip to content

Commit

Permalink
Merge branch 'main' into LilithHafner-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
LilithHafner authored Nov 24, 2024
2 parents ab7106b + c52d8a8 commit d764a62
Show file tree
Hide file tree
Showing 11 changed files with 605 additions and 227 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
8 changes: 4 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ jobs:
- os: macOS-latest
arch: x86
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
- uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
Expand All @@ -45,6 +45,6 @@ jobs:
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v3
with:
file: lcov.info
6 changes: 3 additions & 3 deletions .github/workflows/Invalidations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ jobs:
if: github.base_ref == github.event.repository.default_branch
runs-on: ubuntu-latest
steps:
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2
with:
version: '1'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-invalidations@v1
id: invs_pr

- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
- uses: julia-actions/julia-buildpkg@v1
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Manifest.toml
8 changes: 4 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name = "SortingAlgorithms"
uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c"
version = "1.0.1"
version = "1.2.1"

[deps]
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"

[compat]
julia = "1"
DataStructures = "0.9, 0.10, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18"
StatsBase = "0.33"
julia = "1"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Random", "StatsBase", "Test"]
test = ["Aqua", "Random", "StatsBase", "Test"]
176 changes: 70 additions & 106 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,126 +1,90 @@
# Sorting Algorithms

[![Build status](https://github.com/JuliaLang/SortingAlgorithms.jl/workflows/CI/badge.svg)](https://github.com/JuliaLang/SortingAlgorithms.jl/actions?query=workflow%3ACI+branch%3Amaster)
[![Build status](https://github.com/JuliaLang/SortingAlgorithms.jl/workflows/CI/badge.svg)](https://github.com/JuliaLang/SortingAlgorithms.jl/actions?query=workflow%3ACI+branch%3Amaster)
[![Coverage Status](https://coveralls.io/repos/JuliaLang/SortingAlgorithms.jl/badge.svg)](https://coveralls.io/r/JuliaLang/SortingAlgorithms.jl)
[![deps](https://juliahub.com/docs/SortingAlgorithms/deps.svg)](https://juliahub.com/ui/Packages/SortingAlgorithms/6dCmw?t=2)

The `SortingAlgorithms` package provides three sorting algorithms that can be used with Julia's [standard sorting API](https://docs.julialang.org/en/v1/base/sort/):
The `SortingAlgorithms` package provides four sorting algorithms that can be used with Julia's [standard sorting API](https://docs.julialang.org/en/v1/base/sort/):

- [HeapSort] – an unstable, general purpose, in-place, O(n log n) comparison sort that works by heapifying an array and repeatedly taking the maximal element from the heap.
- [TimSort] – a stable, general purpose, hybrid, O(n log n) comparison sort that adapts to different common patterns of partially ordered input data.
- [RadixSort] – a stable, special case, O(n) non-comparison sort that works by sorting data with fixed size, one digit at a time.
- [CombSort] – an unstable, general purpose, in-place, O(n log n) comparison sort with O(n^2) pathological cases that can attain good efficiency through SIMD instructions and instruction level parallelism on modern hardware.
- [PagedMergeSort] – a stable, general purpose, O(n log n) time and O(sqrt n) space comparison sort.

[HeapSort]: http://en.wikipedia.org/wiki/Heapsort
[TimSort]: http://en.wikipedia.org/wiki/Timsort
[RadixSort]: http://en.wikipedia.org/wiki/Radix_sort
[HeapSort]: https://en.wikipedia.org/wiki/Heapsort
[TimSort]: https://en.wikipedia.org/wiki/Timsort
[CombSort]: https://en.wikipedia.org/wiki/Comb_sort
[PagedMergeSort]: https://link.springer.com/chapter/10.1007/BFb0016253

## Usage

```jl
julia> using SortingAlgorithms
julia> using SortingAlgorithms

julia> words = map(chomp,[readlines(open("/usr/share/dict/words"))...])
235886-element Array{ASCIIString,1}:
"A"
"a"
"aa"
"aal"
"aalii"
"zythem"
"Zythia"
"zythum"
"Zyzomys"
"Zyzzogeton"
julia> words = map(chomp,[readlines(open("/usr/share/dict/words"))...])
235886-element Array{ASCIIString,1}:
"A"
"a"
"aa"
"zythum"
"Zyzomys"
"Zyzzogeton"

julia> sort!(words, alg=TimSort)
235886-element Array{ASCIIString,1}:
"A"
"Aani"
"Aaron"
"Aaronic"
"Aaronical"
"zymotize"
"zymotoxic"
"zymurgy"
"zythem"
"zythum"
julia> sort!(words, alg=TimSort)
235886-element Array{ASCIIString,1}:
"A"
"Aani"
"Aaron"
"zymurgy"
"zythem"
"zythum"

julia> sort!(words, alg=TimSort, by=length)
235886-element Array{ASCIIString,1}:
"A"
"B"
"C"
"D"
"E"
"formaldehydesulphoxylate"
"pathologicopsychological"
"scientificophilosophical"
"tetraiodophenolphthalein"
"thyroparathyroidectomize"
julia> sort!(words, alg=TimSort, by=length)
235886-element Array{ASCIIString,1}:
"A"
"B"
"C"
"scientificophilosophical"
"tetraiodophenolphthalein"
"thyroparathyroidectomize"

julia> sort!(words, alg=HeapSort)
235886-element Array{ASCIIString,1}:
"A"
"Aani"
"Aaron"
"Aaronic"
"Aaronical"
"zymotize"
"zymotoxic"
"zymurgy"
"zythem"
"zythum"
julia> sort!(words, alg=HeapSort)
235886-element Array{ASCIIString,1}:
"A"
"Aani"
"Aaron"
"zymurgy"
"zythem"
"zythum"

julia> sort!(words, alg=HeapSort, by=length)
235886-element Array{ASCIIString,1}:
"L"
"p"
"U"
"I"
"q"
"pathologicopsychological"
"formaldehydesulphoxylate"
"scientificophilosophical"
"tetraiodophenolphthalein"
"thyroparathyroidectomize"
julia> sort!(words, alg=HeapSort, by=length)
235886-element Array{ASCIIString,1}:
"L"
"p"
"U"
"scientificophilosophical"
"tetraiodophenolphthalein"
"thyroparathyroidectomize"

julia> sort!(words, alg=RadixSort)
ERROR: Radix sort only sorts bits types (got ASCIIString)
in error at error.jl:21
in sort! at /Users/stefan/.julia/SortingAlgorithms/src/SortingAlgorithms.jl:54
in sort! at sort.jl:328
in sort! at sort.jl:329

julia> floats = randn(1000)
1000-element Array{Float64,1}:
1.729
0.907196
0.461481
-0.204763
-0.16022
0.700683
-0.236204
-2.15634
-0.316188
-0.171478

julia> sort!(floats, alg=RadixSort)
1000-element Array{Float64,1}:
-2.86255
-2.72041
-2.58234
-2.57259
-2.53046
3.08307
3.12902
3.15075
3.20058
3.23942
julia> sort!(randn(1000), alg=CombSort)
1000-element Array{Float64,1}:
-2.86255
-2.72041
-2.58234
3.15075
3.20058
3.23942
```

## Other packages that provide sorting algorithms

While SortingAlgorithms.jl is the most widely used sorting package in the Julia ecosystem, other packages are available:
- https://github.com/xiaodaigh/SortingLab.jl
- https://github.com/JeffreySarnoff/SortingNetworks.jl
- https://github.com/nlw0/ChipSort.jl
1 change: 1 addition & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
comment: false
Binary file added docs/pagedMerge_130_130.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit d764a62

Please sign in to comment.