Yes, exactly. Sorry I was not especially helpful yesterday – was on my
phone. But you seem to have figured it out. Sorry also that this is not the
most elegant interface. Obviously the longer term is to make passing
functions as arguments more efficient.


On Fri, Jul 4, 2014 at 5:36 AM, gentlebeldin <[email protected]>
wrote:

> I guess you mean something like this:
>
> julia> using Base.Order
>
> julia> import Base.lt
>
> julia> type MyNewOrdering<:Ordering
>        end
>
> julia> f(x::Float64)=x
> f (generic function with 1 method)
>
>
> julia> lt(o::MyNewOrdering,x::Float64,y::Float64)=f(x)<f(y)
> lt (generic function with 9 methods)
>
>
> julia> a=rand(1000000)
> 1000000-element Array{Float64,1}:
> ...
>
> julia> @time sort(a,order=MyNewOrdering())
> elapsed time: 0.119845282 seconds (8000496 bytes allocated)
> 1000000-element Array{Float64,1}:
> ...
>
>
> Yes, that's better, both time and memory allocation. Thank you very much!
> :-)
>
> Am Donnerstag, 3. Juli 2014 21:14:05 UTC+2 schrieb Stefan Karpinski:
>
>> You can also define your own subtype of Order. See base/order.jl.
>>
>>

Reply via email to