Code Monkey home page Code Monkey logo

Comments (3)

mcabbott avatar mcabbott commented on June 12, 2024

Do you have an example of this failing? It ought to work, but perhaps you found a bug:

julia> sort(wrapdims(rand(Int8, 5), 'a':'e'))
1-dimensional KeyedArray(...) with keys:5-element Vector{Char}
And data, 5-element Array{Int8,1}:
 ('e')  -38
 ('a')   -5
 ('d')    3
 ('c')   59
 ('b')   65

from axiskeys.jl.

kcajf avatar kcajf commented on June 12, 2024

Ah great. I just realised I didn't have a 1D array, but a 1xN matrix:

julia> sort(wrapdims(rand(Int8, 1, 5), 1:1, 'a':'e'), dims=2)
2-dimensional KeyedArray(...) with keys:
↓   1-element UnitRange{Int64}
→   5-element OneTo{Int}
And data, 1×5 Array{Int8,2}:
       (1)  (2)  (3)  (4)  (5)
 (1)  -127    4   65   80   96

The behaviour therefore makes sense, given how multidimensional sort works. I would need to drop the first dimension to get the behaviour I wanted.

from axiskeys.jl.

mcabbott avatar mcabbott commented on June 12, 2024

Cool. There is also sortslices for higher-dim arrays:

julia> wrapdims(rand(Int8, 2, 5), 11:12, 'a':'e')
2-dimensional KeyedArray(...) with keys:
↓   2-element UnitRange{Int64}
→   5-element StepRange{Char,...}
And data, 2×5 Array{Int8,2}:
        ('a')  ('b')  ('c')  ('d')   ('e')
 (11)  122     83     81     53     -28
 (12)  -62     39     61      0     -88

julia> sortslices(ans, dims=2)
2-dimensional KeyedArray(...) with keys:
↓   2-element UnitRange{Int64}
→   5-element Vector{Char}
And data, 2×5 Array{Int8,2}:
        ('e')  ('d')  ('c')  ('b')   ('a')
 (11)  -28     53     81     83     122
 (12)  -88      0     61     39     -62

from axiskeys.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.