[RCR] natcmp.rb added to string class

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.

Cheers,

Patrick

Patrick May wrote:

Hello,

Natural Order String Comparison is a useful algorithm:

    Natural Order String Comparison

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

Hello,

thanks for the interest in this. I wrote it ages ago and have completely forgotten about it.

There is a newer version available here...
http://rubyforge.org/projects/natcmp/

Patrick May wrote:

···

Hello,

Natural Order String Comparison is a useful algorithm:

    Natural Order String Comparison

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.

Cheers,

Patrick

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