Skip to content

Commit

Permalink
Merge pull request #3665 from JuliaLang/sk/sort-keywords
Browse files Browse the repository at this point in the history
sorting API refactor: keywords!
  • Loading branch information
StefanKarpinski committed Jul 11, 2013
2 parents 87c164f + af97a6c commit f951d7c
Show file tree
Hide file tree
Showing 12 changed files with 249 additions and 238 deletions.
2 changes: 1 addition & 1 deletion base/darray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function defaultdist(dims, procs)
dims = [dims...]
chunks = ones(Int, length(dims))
np = length(procs)
f = sort!(collect(keys(factor(np))), Sort.Reverse)
f = sort!(collect(keys(factor(np))), rev=true)
k = 1
while np > 1
# repeatedly allocate largest factor to largest dim
Expand Down
68 changes: 67 additions & 1 deletion base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,73 @@ export assign
typealias ComplexPair Complex
export ComplexPair

## along an axis
# superseded sorting API

@deprecate select(v::AbstractVector,k::Union(Int,Range1),o::Ordering) select(v,k,order=o)
@deprecate select(v::AbstractVector,k::Union(Int,Range1),f::Function) select(v,k,lt=f)
@deprecate select(f::Function,v::AbstractVector,k::Union(Int,Range1)) select(v,k,lt=f)

# @deprecate select!(v::AbstractVector,k::Union(Int,Range1),o::Ordering) select!(v,k,order=o)
@deprecate select!(v::AbstractVector,k::Union(Int,Range1),f::Function) select!(v,k,lt=f)
@deprecate select!(f::Function,v::AbstractVector,k::k::Union(Int,Range1)) select!(v,k,lt=f)

@deprecate sort(v::AbstractVector,o::Ordering) sort(v,order=o)
@deprecate sort(v::AbstractVector,a::Algorithm) sort(v,alg=a)
@deprecate sort(v::AbstractVector,a::Algorithm,o::Ordering) sort(v,alg=a,order=o)
@deprecate sort(v::AbstractVector,o::Ordering,a::Algorithm) sort(v,alg=a,order=o)
@deprecate sort(v::AbstractVector,f::Function) sort(v,lt=f)
@deprecate sort(v::AbstractVector,a::Algorithm,f::Function) sort(v,alg=a,lt=f)
@deprecate sort(v::AbstractVector,f::Function,a::Algorithm) sort(v,alg=a,lt=f)
@deprecate sort(f::Function,v::AbstractVector,a::Algorithm) sort(v,alg=a,lt=f)

@deprecate sort!(v::AbstractVector,o::Ordering) sort!(v,order=o)
@deprecate sort!(v::AbstractVector,a::Algorithm) sort!(v,alg=a)
# @deprecate sort!(v::AbstractVector,a::Algorithm,o::Ordering) sort!(v,alg=a,order=o)
@deprecate sort!(v::AbstractVector,o::Ordering,a::Algorithm) sort!(v,alg=a,order=o)
@deprecate sort!(v::AbstractVector,f::Function) sort!(v,lt=f)
@deprecate sort!(v::AbstractVector,a::Algorithm,f::Function) sort!(v,alg=a,lt=f)
@deprecate sort!(v::AbstractVector,f::Function,a::Algorithm) sort!(v,alg=a,lt=f)
@deprecate sort!(f::Function,v::AbstractVector,a::Algorithm) sort!(v,alg=a,lt=f)

@deprecate sortperm(v::AbstractVector,o::Ordering) sortperm(v,order=o)
@deprecate sortperm(v::AbstractVector,a::Algorithm) sortperm(v,alg=a)
@deprecate sortperm(v::AbstractVector,a::Algorithm,o::Ordering) sortperm(v,alg=a,order=o)
@deprecate sortperm(v::AbstractVector,o::Ordering,a::Algorithm) sortperm(v,alg=a,order=o)
@deprecate sortperm(v::AbstractVector,f::Function) sortperm(v,lt=f)
@deprecate sortperm(v::AbstractVector,a::Algorithm,f::Function) sortperm(v,alg=a,lt=f)
@deprecate sortperm(v::AbstractVector,f::Function,a::Algorithm) sortperm(v,alg=a,lt=f)
@deprecate sortperm(f::Function,v::AbstractVector,a::Algorithm) sortperm(v,alg=a,lt=f)

@deprecate sort(v::AbstractVector,d::Integer,o::Ordering) sort(v,d,order=o)
@deprecate sort(v::AbstractVector,d::Integer,a::Algorithm) sort(v,d,alg=a)
@deprecate sort(v::AbstractVector,d::Integer,a::Algorithm,o::Ordering) sort(v,d,alg=a,order=o)
@deprecate sort(v::AbstractVector,d::Integer,o::Ordering,a::Algorithm) sort(v,d,alg=a,order=o)

@deprecate sort!(v::AbstractVector,d::Integer,o::Ordering) sort!(v,d,order=o)
@deprecate sort!(v::AbstractVector,d::Integer,a::Algorithm) sort!(v,d,alg=a)
@deprecate sort!(v::AbstractVector,d::Integer,a::Algorithm,o::Ordering) sort!(v,d,alg=a,order=o)
@deprecate sort!(v::AbstractVector,d::Integer,o::Ordering,a::Algorithm) sort!(v,d,alg=a,order=o)

@deprecate sortby(v::AbstractVector,f::Function) sort(v,by=f)
@deprecate sortby(v::AbstractVector,a::Algorithm,f::Function) sort(v,alg=a,by=f)
@deprecate sortby(v::AbstractVector,f::Function,a::Algorithm) sort(v,alg=a,by=f)
@deprecate sortby(f::Function,v::AbstractVector,a::Algorithm) sort(v,alg=a,by=f)

@deprecate sortby!(v::AbstractVector,f::Function) sortby!(v,by=f)
@deprecate sortby!(v::AbstractVector,a::Algorithm,f::Function) sort!(v,alg=a,by=f)
@deprecate sortby!(v::AbstractVector,f::Function,a::Algorithm) sort!(v,alg=a,by=f)
@deprecate sortby!(f::Function,v::AbstractVector,a::Algorithm) sort!(v,alg=a,by=f)

@deprecate sortrows(v::AbstractMatrix,o::Ordering) sortrows(v,order=o)
@deprecate sortrows(v::AbstractMatrix,a::Algorithm) sortrows(v,alg=a)
@deprecate sortrows(v::AbstractMatrix,a::Algorithm,o::Ordering) sortrows(v,alg=a,order=o)
@deprecate sortrows(v::AbstractMatrix,o::Ordering,a::Algorithm) sortrows(v,alg=a,order=o)

@deprecate sortcols(v::AbstractMatrix,o::Ordering) sortcols(v,order=o)
@deprecate sortcols(v::AbstractMatrix,a::Algorithm) sortcols(v,alg=a)
@deprecate sortcols(v::AbstractMatrix,a::Algorithm,o::Ordering) sortcols(v,alg=a,order=o)
@deprecate sortcols(v::AbstractMatrix,o::Ordering,a::Algorithm) sortcols(v,alg=a,order=o)

function amap(f::Function, A::AbstractArray, axis::Integer)
warn_once("amap is deprecated, use mapslices(f, A, dims) instead")
dimsA = size(A)
Expand Down
2 changes: 0 additions & 2 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,6 @@ export
slicedim,
sort,
sort!,
sortby,
sortby!,
sortperm,
sortrows,
sortcols,
Expand Down
6 changes: 3 additions & 3 deletions base/pkg/resolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ function decimate(n::Int, graph::Graph, msgs::Messages)
#println("DECIMATING $n NODES")
fld = msgs.fld
decimated = msgs.decimated
fldorder = sortperm(fld, Sort.By(secondmax))
fldorder = sortperm(fld, by=secondmax)
for p0 in fldorder
if decimated[p0]
continue
Expand Down Expand Up @@ -1300,7 +1300,7 @@ function sanity_check(vers::Vector{Version}, deps::Vector{(Version,VersionSet)})
p0, v0 = vdict[v]
return -pndeps[p0][v0]
end
svers = sortby(vers, vrank)
svers = sort(vers, by=vrank)

nv = length(svers)

Expand Down Expand Up @@ -1373,7 +1373,7 @@ function sanity_check(vers::Vector{Version}, deps::Vector{(Version,VersionSet)})
end
i += 1
end
sortby!(insane, x->x[1])
sort!(insane, by=x->x[1])
throw(MetadataError(insane))
end

Expand Down
2 changes: 1 addition & 1 deletion base/pkg2/resolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function sanity_check(deps::Dict{ByteString,Dict{VersionNumber,Available}})
for (p,d) in deps, (vn,_) in d
push!(vers, (p,vn))
end
sortby!(vers, pvn->(-ndeps[pvn[1]][pvn[2]]))
sort!(vers, by=pvn->(-ndeps[pvn[1]][pvn[2]]))

nv = length(vers)

Expand Down
2 changes: 1 addition & 1 deletion base/pkg2/resolve/maxsum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ function decimate(n::Int, graph::Graph, msgs::Messages)
#println("DECIMATING $n NODES")
fld = msgs.fld
decimated = msgs.decimated
fldorder = sortperm(fld, Sort.By(secondmax))
fldorder = sortperm(fld, by=secondmax)
for p0 in fldorder
if decimated[p0]
continue
Expand Down
2 changes: 1 addition & 1 deletion base/pkg2/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Base.contains(s::VersionSet, v::VersionNumber) = any(i->contains(i,v), s.interva
function Base.intersect(A::VersionSet, B::VersionSet)
ivals = vec([ intersect(a,b) for a in A.intervals, b in B.intervals ])
filter!(i->!isempty(i), ivals)
sortby!(ivals, i->i.lower)
sort!(ivals, by=i->i.lower)
VersionSet(ivals)
end
Base.isequal(A::VersionSet, B::VersionSet) = (A.intervals == B.intervals)
Expand Down
2 changes: 1 addition & 1 deletion base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function _subtypes(m::Module, x::DataType, sts=Set(), visited=Set())
end
sts
end
subtypes(m::Module, x::DataType) = sortby(string, collect(_subtypes(m, x)))
subtypes(m::Module, x::DataType) = sort(collect(_subtypes(m, x)), by=string)
subtypes(x::DataType) = subtypes(Main, x)

subtypetree(x::DataType, level=-1) = (level == 0 ? (x, {}) : (x, {subtypetree(y, level-1) for y in subtypes(x)}))
Expand Down
Loading

0 comments on commit f951d7c

Please sign in to comment.