Skip to content

Commit

Permalink
Merge be808dc into 5cf1627
Browse files Browse the repository at this point in the history
  • Loading branch information
sostock authored Dec 8, 2022
2 parents 5cf1627 + be808dc commit 78f0bba
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function show(io::IO, x::Unitlike)
showoperators = get(io, :showoperators, false)
first = ""
sep = showoperators ? "*" : " "
foreach(sortexp(typeof(x).parameters[1])) do y
foreach(sortexp(x)) do y
print(io,first)
showrep(io,y)
first = sep
Expand All @@ -182,10 +182,9 @@ end
sortexp(xs)
Sort units to show positive exponents first.
"""
function sortexp(xs)
vcat([x for x in xs if power(x) >= 0],
[x for x in xs if power(x) < 0])
end
sortexp(xs) = sort!(collect(xs), by = u->signbit(power(u)), alg = InsertionSort)
@generated sortexp(::Dimensions{D}) where D = (sortexp(D)...,)
@generated sortexp(::Units{U}) where U = (sortexp(U)...,)

"""
showrep(io::IO, x::Unit)
Expand Down

0 comments on commit 78f0bba

Please sign in to comment.