[RCR] natcmp.rb added to string class

Discussion in 'Ruby' started by Patrick May, Jul 31, 2004.

  1. Patrick May

    Patrick May Guest

    Patrick May, Jul 31, 2004
    #1
    1. Advertising

  2. Patrick May wrote:
    > Hello,
    >
    > Natural Order String Comparison is a useful algorithm:
    >
    > http://sourcefrog.net/projects/natsort/
    >
    > Alan Davies wrote an implementation of the algorithm in ruby, and it is
    > useful:
    >
    > http://sourcefrog.net/projects/natsort/natcmp.rb
    >
    > I think it would be nice if String always had this method. I hope there
    > aren't license conflicts.


    Hm, I think it's good to have this as an external library. This could
    then extend both String and Array classes. E.g.

    require 'natsort'

    ["a10", "a2"].sort {|a,b| a.natcmp(b) }
    # or
    ["a10", "a2"].natsort

    Regards,

    Michael
     
    Michael Neumann, Aug 1, 2004
    #2
    1. Advertising

  3. Patrick May

    Patrick May Guest

    Hello,

    On Sunday, August 1, 2004, at 03:56 AM, Michael Neumann wrote:

    > Hm, I think it's good to have this as an external library. This could
    > then extend both String and Array classes. E.g.
    >
    > require 'natsort'
    >
    > ["a10", "a2"].sort {|a,b| a.natcmp(b) }
    > # or
    > ["a10", "a2"].natsort


    The only reason I think that this would be better as a standard
    library, instead of being directly on String and Array, is that it
    would be easier to maintain the code. From a user point of view, I'd
    like those functions to just be on String.

    Cheers,

    Patrick
     
    Patrick May, Aug 1, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bennett Haselton
    Replies:
    1
    Views:
    516
    John M Deal
    Nov 8, 2004
  2. Matthias Georgi

    [RCR] subclasses of string as hash keys

    Matthias Georgi, May 13, 2004, in forum: Ruby
    Replies:
    14
    Views:
    170
    Robert Klemme
    May 17, 2004
  3. Simon Strandgaard

    [rcr] epsilon string escaping in %W()

    Simon Strandgaard, Aug 7, 2004, in forum: Ruby
    Replies:
    1
    Views:
    108
    Simon Strandgaard
    Aug 7, 2004
  4. Simon Strandgaard

    [rcr] String#first / String#last

    Simon Strandgaard, Oct 24, 2004, in forum: Ruby
    Replies:
    29
    Views:
    240
    Brian Candler
    Oct 26, 2004
  5. Stefan Rusterholz
    Replies:
    34
    Views:
    337
    Robert Dober
    Jul 21, 2007
Loading...

Share This Page