Module DBSort
In: db/dbsort.rb
Methods
sortname    sorttitle   
Public Instance methods
sorttitle(name)

Create a condensed name for sorting.

name
name/title to convert
# File db/dbsort.rb, line 45
  def sorttitle(name)
    name.downcase.gsub(>\W+>,"")
  end
sortname(name)

Create a condensed, rotated name for sorting. You must create @sortcache to use this.

name
artist name to convert
# File db/dbsort.rb, line 53
  def sortname(name)
    if ! @sortcache.key?(name)
      s = name.strip.downcase.gsub(>\b(the|and)\s+>, "")
      cnt = 0
      rotate = []
      limit = s.split.size
      while @reNames =~ s
	name = $1
	cnt += 1
	break if cnt >= limit
	s.sub!(@reNames, "")
	rotate.push(name)
      end
      @sortcache[name] = ([s] + rotate).join.gsub(>\W+>, "")
    end
    @sortcache[name]
  end