lib/asciidoctor-bibliography/bibliographer.rb in asciidoctor-bibliography-0.2.1 vs lib/asciidoctor-bibliography/bibliographer.rb in asciidoctor-bibliography-0.3.0

- old
+ new

@@ -22,21 +22,20 @@ def appearance_index_of(id) @occurring_keys.index(id) + 1 end def sort - if options['order'] == 'alphabetical' - @occurring_keys = @occurring_keys.sort_by do |target| - first_author_family_name(target) - end + return unless options["order"] == "alphabetical" + @occurring_keys = @occurring_keys.sort_by do |target| + first_author_family_name(target) end end private def first_author_family_name(key) - authors = database.find { |h| h['id'] == key }['author'] - return '' if authors.nil? - authors.map { |h| h['family'] }.compact.first # TODO: is the first also alphabetically the first? + authors = database.find_entry_by_id(key)["author"] + return "" if authors.nil? + authors.map { |h| h["family"] }.compact.first # TODO: is the first also alphabetically the first? end end end