Skip to content

Commit a5b9490

Browse files
update LICENSE, fill in README, add .travis.yml file [close #2]
1 parent bf1e0f4 commit a5b9490

File tree

3 files changed

+140
-1
lines changed

3 files changed

+140
-1
lines changed

.travis.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
language: cpp
2+
compiler:
3+
- clang
4+
notifications:
5+
email: false
6+
env:
7+
matrix:
8+
- JULIAVERSION="juliareleases"
9+
- JULIAVERSION="julianightlies"
10+
before_install:
11+
- sudo add-apt-repository ppa:staticfloat/julia-deps -y
12+
- sudo add-apt-repository ppa:staticfloat/${JULIAVERSION} -y
13+
- sudo apt-get update -qq -y
14+
- sudo apt-get install libpcre3-dev julia -y
15+
script:
16+
- julia -e 'Pkg.init(); run(`ln -s $(pwd()) $(Pkg.dir("SortingAlgorithms"))`); Pkg.pin("SortingAlgorithms"); Pkg.resolve()'
17+
- julia -e 'using SortingAlgorithms; @assert isdefined(:SortingAlgorithms); @assert typeof(SortingAlgorithms) === Module'

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The SortingAlgorithms.jl package is licensed under the MIT Expat License:
22

3-
> Copyright (c) 2013: Jeff Bezanson.
3+
> Copyright (c) 2013-2014: Kevin Squire, Stefan Karpinski, Jeff Bezanson.
44
>
55
> Permission is hereby granted, free of charge, to any person obtaining
66
> a copy of this software and associated documentation files (the

README.md

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# SortingAlgorithms
2+
3+
[![Build Status](https://travis-ci.org/StefanKarpinski/SortingAlgorithms.jl.png)](https://travis-ci.org/StefanKarpinski/SortingAlgorithms.jl)
4+
5+
The SortingAlgorithms package provides three sorting algorithms that can be used with Julia's [standard sorting APIs](http://docs.julialang.org/en/latest/stdlib/sort/):
6+
7+
- [HeapSort] – an unstable, general purpose, in-place, O(n log n) comparison sort that works by heapify an array and repeatedly taking the maximal element from the heap.
8+
- [TimSort] – a stable, general purpose, hybrid, O(n log n) comparison sort that adapts to different common patterns of partially ordered input data.
9+
- [RadixSort] – a stable, special case, in-place, O(n) non-comparison sort that works by sorting data with fixed size, one digit at a time.
10+
11+
[HeapSort] http://en.wikipedia.org/wiki/Heapsort
12+
[TimSort] http://en.wikipedia.org/wiki/Timsort
13+
[RadixSort] http://en.wikipedia.org/wiki/Radix_sort
14+
15+
## Usage
16+
17+
julia> using SortingAlgorithms
18+
19+
julia> words = map(chomp,[readlines(open("/usr/share/dict/words"))...])
20+
235886-element Array{ASCIIString,1}:
21+
"A"
22+
"a"
23+
"aa"
24+
"aal"
25+
"aalii"
26+
27+
"zythem"
28+
"Zythia"
29+
"zythum"
30+
"Zyzomys"
31+
"Zyzzogeton"
32+
33+
julia> sort!(words, alg=TimSort)
34+
235886-element Array{ASCIIString,1}:
35+
"A"
36+
"Aani"
37+
"Aaron"
38+
"Aaronic"
39+
"Aaronical"
40+
41+
"zymotize"
42+
"zymotoxic"
43+
"zymurgy"
44+
"zythem"
45+
"zythum"
46+
47+
julia> sort!(words, alg=TimSort, by=length)
48+
235886-element Array{ASCIIString,1}:
49+
"A"
50+
"B"
51+
"C"
52+
"D"
53+
"E"
54+
55+
"formaldehydesulphoxylate"
56+
"pathologicopsychological"
57+
"scientificophilosophical"
58+
"tetraiodophenolphthalein"
59+
"thyroparathyroidectomize"
60+
61+
julia> sort!(words, alg=HeapSort)
62+
235886-element Array{ASCIIString,1}:
63+
"A"
64+
"Aani"
65+
"Aaron"
66+
"Aaronic"
67+
"Aaronical"
68+
69+
"zymotize"
70+
"zymotoxic"
71+
"zymurgy"
72+
"zythem"
73+
"zythum"
74+
75+
julia> sort!(words, alg=HeapSort, by=length)
76+
235886-element Array{ASCIIString,1}:
77+
"L"
78+
"p"
79+
"U"
80+
"I"
81+
"q"
82+
83+
"pathologicopsychological"
84+
"formaldehydesulphoxylate"
85+
"scientificophilosophical"
86+
"tetraiodophenolphthalein"
87+
"thyroparathyroidectomize"
88+
89+
julia> sort!(words, alg=RadixSort)
90+
ERROR: Radix sort only sorts bits types (got ASCIIString)
91+
in error at error.jl:21
92+
in sort! at /Users/stefan/.julia/SortingAlgorithms/src/SortingAlgorithms.jl:54
93+
in sort! at sort.jl:328
94+
in sort! at sort.jl:329
95+
96+
julia> floats = randn(1000)
97+
1000-element Array{Float64,1}:
98+
1.729
99+
0.907196
100+
0.461481
101+
-0.204763
102+
-0.16022
103+
104+
0.700683
105+
-0.236204
106+
-2.15634
107+
-0.316188
108+
-0.171478
109+
110+
julia> sort!(floats, alg=RadixSort)
111+
1000-element Array{Float64,1}:
112+
-2.86255
113+
-2.72041
114+
-2.58234
115+
-2.57259
116+
-2.53046
117+
118+
3.08307
119+
3.12902
120+
3.15075
121+
3.20058
122+
3.23942

0 commit comments

Comments
 (0)