inukshuk / bibtex-ruby

A BibTeX library, parser, and converter for Ruby.
http://inukshuk.github.com/bibtex-ruby
GNU General Public License v3.0
156 stars 31 forks source link

Improve Sorting of Bibliographies #50

Closed inukshuk closed 10 years ago

casutton commented 10 years ago

Actually, I think that sorting of bibliographies is broken. Currently the sort method of Bibliography does nothing: it non-destructively sorts the data, throws away the sorted list, and returns the original object. I think you problem meant to either use sort! or to not return self.

I can submit a pull request for this if you'd like. I wasn't sure whether to do this, though, because it seemed like the root cause might be elsewhere. Ordinarily the sort method wouldn't be required at all, right?

inukshuk commented 10 years ago

You're spot on, this was supposed to be sort! originally; however, since this is contingent on #49 (we've also discussed this here #70) I have not touched in a while.

As I see it now, I think the best approach would be to rename the method to sort! (and use the bang method internally like you suggest) and add a new sort method like this:

def sort(*arguments, &block)
  dup.sort(*arguments, &block)
end

What do you think?

casutton commented 10 years ago

Yes, I agree. I've created a pull request for this.