September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -0,0 +1 @@
|
|||
[1, 1.1, [1,2], true, false, null, {"a":1}, null] | sort
|
||||
|
|
@ -0,0 +1 @@
|
|||
[null,null,false,true,1,1.1,[1,2],{"a":1}]
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
def quicksort:
|
||||
if length < 2 then . # it is already sorted
|
||||
else .[0] as $pivot
|
||||
| reduce .[] as $x
|
||||
# state: [less, equal, greater]
|
||||
( [ [], [], [] ]; # three empty arrays:
|
||||
if $x < $pivot then .[0] += [$x] # add x to less
|
||||
elif $x == $pivot then .[1] += [$x] # add x to equal
|
||||
else .[2] += [$x] # add x to greater
|
||||
end
|
||||
)
|
||||
| (.[0] | quicksort ) + .[1] + (.[2] | quicksort )
|
||||
end ;
|
||||
Loading…
Add table
Add a link
Reference in a new issue