From 88b238da441805e40834a231f364dd3ce896ef77 Mon Sep 17 00:00:00 2001 From: Alexander Munch-Hansen Date: Mon, 21 Oct 2019 16:21:00 +0200 Subject: [PATCH] huhu --- sorting_algos.rb | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/sorting_algos.rb b/sorting_algos.rb index e9611e2..0bdb6a2 100644 --- a/sorting_algos.rb +++ b/sorting_algos.rb @@ -22,18 +22,19 @@ def compare_to(sortings) end - if defined? third - "if (#{(comp first)[:if]}) { - return #{(comp first)[:ret]}; - } else if (#{(comp second)[:if]}) { - return #{(comp second)[:ret]}; - } - return #{(comp third)[:ret]};" - else - "if (#{(comp first)[:if]}) { - return #{(comp first)[:ret]}; - } - return #{(comp second)[:ret]}; - " + pls = sortings.slice(1,sortings.length - 2).map do |ele| + " else if (#{(comp ele)[:if]}) { + return #{(comp ele)[:ret]}; + }" end + + + + + "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