Module: HTTP::Accept::Sort

Defined in:
lib/http/accept/sort.rb

Class Method Summary collapse

Class Method Details

.by_quality_factor(items) ⇒ Object

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



27
28
29
30
# 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