module FakeRedis::SortMethod

def extract_options_from(options_array)

def extract_options_from(options_array)
  # Defaults
  options = {
    :limit => [],
    :order => "ASC",
    :get => []
  }
  if options_array.first == "BY"
    options_array.shift
    options[:by] = options_array.shift
  end
  if options_array.first == "LIMIT"
    options_array.shift
    options[:limit] = [options_array.shift, options_array.shift]
  end
  while options_array.first == "GET"
    options_array.shift
    options[:get] << options_array.shift
  end
  if %w(ASC DESC ALPHA).include?(options_array.first)
    options[:order] = options_array.shift
    options[:order] = "ASC" if options[:order] == "ALPHA"
  end
  if options_array.first == "STORE"
    options_array.shift
    options[:store] = options_array.shift
  end
  options
end