module HTTP::Accept::Sort

Public Class Methods

by_quality_factor(items) click to toggle source

This sorts items with higher priority first, and keeps items with the same priority in the same relative order.

# File lib/http/accept/sort.rb, line 27
def self.by_quality_factor(items)
        # We do this to get a stable sort:
        items.sort_by.with_index{|object, index| [-object.quality_factor, index]}
end