From aad51d646812804052ce2ae5e926b667b4e24d6d Mon Sep 17 00:00:00 2001 From: realtradam Date: Mon, 3 Jan 2022 08:19:24 -0500 Subject: . --- lib/felflame/order.rb | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'lib/felflame/order.rb') diff --git a/lib/felflame/order.rb b/lib/felflame/order.rb index 0bed66b..3202b25 100644 --- a/lib/felflame/order.rb +++ b/lib/felflame/order.rb @@ -1,6 +1,23 @@ module FelFlame module Order - def sort(*sortables) + + # Sets the priority of all items passed into this method + # according to the order they were passed. + # If an array is one of the elements then it will give all + # of those elements in the array the same priority. + # @param sortables [(Systems and Array) or (Scenes and Array)] + # @return [Boolean] +true+. + def self.sort(*sortables) + sortables.each_with_index do |sorted, index| + if sorted.respond_to? :priority + sorted.priority = index + else + sorted.each do |item| + item.priority = index + end + end + end + true end end end -- cgit v1.2.3