lib/marc_cleanup/bib_rubymarc_fixes.rb
### Default field sort: sort fixed fields numerically, then sort the rest
###   in groups, leaving the order of fields within the group alone
Default field sort: sort fixed fields numerically, then sort the rest
in groups, leaving the order of fields within the group alone
Default field sort : sort fixed fields numerically then sort the rest in groups leaving the order of fields within the group alone
def field_sort(record)
    new_rec = MARC::Record.new
    new_rec.leader = record.leader
    record.fields('001'..'009').sort_by { |field| field.tag }.each do |field|
      new_rec.append(field)
    end
    record.fields('010'..'099').each do |field|
      new_rec.append(field)
    end
    record.fields('100'..'199').each do |field|
      new_rec.append(field)
    end
    record.fields('200'..'299').each do |field|
      new_rec.append(field)
    end
    record.fields('300'..'399').each do |field|
      new_rec.append(field)
    end
    record.fields('400'..'499').each do |field|
      new_rec.append(field)
    end
    record.fields('500'..'599').each do |field|
      new_rec.append(field)
    end
    record.fields('600'..'699').each do |field|
      new_rec.append(field)
    end
    record.fields('700'..'799').each do |field|
      new_rec.append(field)
    end
    record.fields('800'..'899').each do |field|
      new_rec.append(field)
    end
    record.fields('900'..'999').each do |field|
      new_rec.append(field)
    end
    new_rec
  end
def field_sort ( record ) new_rec = MARC :: Record . new new_rec . leader = record . leader record . fields ( '001' .. '009' ) . sort_by { | field | field . tag } . each do | field | new_rec . append ( field ) end record . fields ( '010' .. '099' ) . each do | field | new_rec . append ( field ) end record . fields ( '100' .. '199' ) . each do | field | new_rec . append ( field ) end record . fields ( '200' .. '299' ) . each do | field | new_rec . append ( field ) end record . fields ( '300' .. '399' ) . each do | field | new_rec . append ( field ) end record . fields ( '400' .. '499' ) . each do | field | new_rec . append ( field ) end record . fields ( '500' .. '599' ) . each do | field | new_rec . append ( field ) end record . fields ( '600' .. '699' ) . each do | field | new_rec . append ( field ) end record . fields ( '700' .. '799' ) . each do | field | new_rec . append ( field ) end record . fields ( '800' .. '899' ) . each do | field | new_rec . append ( field ) end record . fields ( '900' .. '999' ) . each do | field | new_rec . append ( field ) end new_rec end
Default field sort: sort fixed fields numerically, then sort the rest
in groups, leaving the order of fields within the group alone
Default field sort : sort fixed fields numerically then sort the rest in groups leaving the order of fields within the group alone
record