Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
9
Task/Sort-stability/Elixir/sort-stability-1.elixir
Normal file
9
Task/Sort-stability/Elixir/sort-stability-1.elixir
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
cities = [ {"UK", "London"},
|
||||
{"US", "New York"},
|
||||
{"US", "Birmingham"},
|
||||
{"UK", "Birmingham"} ]
|
||||
|
||||
IO.inspect Enum.sort(cities)
|
||||
IO.inspect Enum.sort(cities, fn a,b -> elem(a,0) >= elem(b,0) end)
|
||||
IO.inspect Enum.sort_by(cities, fn {country, _city} -> country end)
|
||||
IO.inspect Enum.sort_by(cities, fn {_country, city} -> city end)
|
||||
1
Task/Sort-stability/Elixir/sort-stability-2.elixir
Normal file
1
Task/Sort-stability/Elixir/sort-stability-2.elixir
Normal file
|
|
@ -0,0 +1 @@
|
|||
IO.inspect Enum.sort(cities, fn a,b -> elem(a,0) > elem(b,0) end)
|
||||
28
Task/Sort-stability/Liberty-BASIC/sort-stability.liberty
Normal file
28
Task/Sort-stability/Liberty-BASIC/sort-stability.liberty
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
randomize 0.5
|
||||
N=15
|
||||
dim a(N,2)
|
||||
|
||||
for i = 0 to N-1
|
||||
a(i,1)= int(i/5)
|
||||
a(i,2)= int(rnd(1)*5)
|
||||
next
|
||||
|
||||
print "Unsorted by column #2"
|
||||
print "by construction sorted by column #1"
|
||||
for i = 0 to N-1
|
||||
print a(i,1), a(i,2)
|
||||
next
|
||||
|
||||
sort a(), 0, N-1, 2
|
||||
print
|
||||
|
||||
print "After sorting by column #2"
|
||||
print "Notice wrong order by column #1"
|
||||
for i = 0 to N-1
|
||||
print a(i,1), a(i,2),
|
||||
if i=0 then
|
||||
print
|
||||
else
|
||||
if a(i,2) = a(i-1,2) AND a(i,1) < a(i-1,1) then print "bad order" else print
|
||||
end if
|
||||
next
|
||||
Loading…
Add table
Add a link
Reference in a new issue