diff --git a/sorting_algos.rb b/sorting_algos.rb index 1a0f278..2b583ee 100644 --- a/sorting_algos.rb +++ b/sorting_algos.rb @@ -19,21 +19,16 @@ def compare_to(sortings) :ret => (return_stat.call sorting)[:ret]} end} - - pls = sortings.slice(1,sortings.length - 2).map do |ele| - " else if (#{(comp ele)[:if]}) { - return #{(comp ele)[:ret]}; - }" + "else if (#{(comp.call ele)[:if]}) { +\t\t\treturn #{(comp.call ele)[:ret]}; +\t\t}" end + "\t\tif (#{(comp.call first)[:if]}) { +\t\t\treturn #{(comp.call first)[:ret]}; +\t\t} +\t\t#{pls.join "\n"} +\t\treturn #{(comp.call sortings[sortings.length-1])[:ret]};" - - - "if (#{(comp first)[:if]}) { - return #{(comp first)[:ret]}; - } - #{pls.join "\n"} - return #{(comp sortings[sortings.length-1])[:ret]};" - end \ No newline at end of file