Code Monkey home page Code Monkey logo

sort-naturally-xs's People

Contributors

caballerosteam avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

akoruchejohn

sort-naturally-xs's Issues

dies on unicode strings (e.g. โ˜ƒ)

Hi! Thank you for writing Sort::Naturally::XS, it looks really great.

I'm having trouble using it though because right now it die()s whenever it tries to sort strings with UTF-8 characters. Here's the simplest example I could come up with to reproduce it:

perl -MSort::Naturally::XS -E 'my @l = ( qq(\x{2603}), q(abc) ); say join q(, ) => nsort(@l)'
Wide character in subroutine entry at -e line 1.

Ideally, Sort::Naturally::XS would use the Unicode Collation Algorithm to compare unicode characters/strings, but even just giving it some sort of fixed sort value (instead of raising an exception) and documenting this should be enough I guess.

Hope this helps! And thanks again for writing and maintaining Sort::Naturally::XS!

empty list should sort to another empty list, not (undef)

Hi! First of all, let me thank you again for writing and maintaining Sort::Naturally::XS. I've been making some tests with it and it looks like it really speed things up!

The issue here is with the return value of nsort. Whenever it gets an empty list, instead of returning another empty list (e.g. ()) it is returning undef, which behaves as a single element when in list context. This is a very common issue with list/scalar context!

perl -MSort::Naturally::XS -E 'my @l; say scalar @l; my @o = nsort(@l); say scalar @o'
0
1

So if I do (a common case, I suspect):

   @list = nsort( @list );

and @list is empty (e.g ()), then after the call to nsort it will not be empty anymore, and instead contain 1 element: (undef). In fact:

> perl -Ilib  -MSort::Naturally::XS -E 'my @l; @l = nsort(@l); use DDP; p @l'
[
  [0]  undef
]

The solution is returning the empty list (), which in scalar context is undef and in list context is, well, an actual empty list :)

Hope this helps! Thanks again for writing such an interesting module!

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.