I think the problem here is that implementing sort(r::Range; rev::Bool=false), i.e. for keyword rev only, is that it would mean there is no definition for the other keyword arguments. Alternatively, if the other keywords were implemented for Range, then the method would not be type-stable. As Steven pointed out, sort(-5:5, by=abs) could not be represented by a Range.
Admittedly I was initially confused about dispatch with keyword arguments, and my understanding is still quite tenuous. If what I'm saying makes sense then I don't think there is a case for filing an issue/PR? On Friday, May 6, 2016 at 2:36:27 AM UTC+10, Milan Bouchet-Valat wrote: > Le dimanche 01 mai 2016 à 19:11 -0700, 'Greg Plowman' via julia-users a > écrit : > > > > Extending/overwriting sort in range.jl (line 686) > > > > sort(r::Range) = issorted(r) ? r : reverse(r) > > > > with the following worked for me. > > > > function Base.sort(r::Range; rev::Bool=false) > > if rev > > issorted(r) ? reverse(r) : r > > else > > issorted(r) ? r : reverse(r) > > end > > end > Makes sense, please file an issue or a pull request (if the latter, be > sure to also add tests to prevent regressions). > > > Regards >
