Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

View file

@ -0,0 +1,43 @@
with Gnat.Heap_Sort_G;
procedure Integer_Sort is
-- Heap sort package requires data to be in index values starting at
-- 1 while index value 0 is used as temporary storage
type Int_Array is array(Natural range <>) of Integer;
Values : Int_Array := (0,1,8,2,7,3,6,4,5);
-- define move and less than subprograms for use by the heap sort package
procedure Move_Int(From : Natural; To : Natural) is
begin
Values(To) := Values(From);
end Move_Int;
function Lt_Int(Left, Right : Natural) return Boolean is
begin
return Values(Left) < Values (Right);
end Lt_Int;
-- Instantiate the generic heap sort package
package Heap_Sort is new Gnat.Heap_Sort_G(Move_Int, Lt_Int);
begin
Heap_Sort.Sort(8);
end Integer_Sort;
requires an Ada05 compiler, e.g GNAT GPL 2007
with Ada.Containers.Generic_Array_Sort;
procedure Integer_Sort is
--
type Int_Array is array(Natural range <>) of Integer;
Values : Int_Array := (0,1,8,2,7,3,6,4,5);
-- Instantiate the generic sort package from the standard Ada library
procedure Sort is new Ada.Containers.Generic_Array_Sort
(Index_Type => Natural,
Element_Type => Integer,
Array_Type => Int_Array);
begin
Sort(Values);
end Integer_Sort;

View file

@ -0,0 +1,20 @@
@if defined doSort goto sort
@echo off
setlocal enabledelayedexpansion
(set lf=^
)
set doSort=1
set nums=!lf!765!lf!1232!lf!457615!lf!29681!lf!20932
echo Before:
set nums | more +1
echo After:
for /f %%i in ('cmd /q /v:on /e:on /d /c "%~f0" ^| sort') do echo/%%i
goto:eof
:sort
for /f %%i in ("!nums!") do (
REM 12 leading spaces:
set "Z= %%i"
REM take last 12 digits:
echo !Z:~-12!
)

View file

@ -0,0 +1,22 @@
PROGRAM-ID. sort-ints.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 array-area VALUE "54321".
03 array PIC 9 OCCURS 5 TIMES.
01 i PIC 9.
PROCEDURE DIVISION.
main-line.
PERFORM display-array
SORT array ASCENDING array
PERFORM display-array
GOBACK
.
display-array.
PERFORM VARYING i FROM 1 BY 1 UNTIL 5 < i
DISPLAY array (i) " " NO ADVANCING
END-PERFORM
DISPLAY SPACE
.

View file

@ -0,0 +1,2 @@
include sort.e
print(1,sort({20, 7, 65, 10, 3, 0, 8, -60}))

View file

@ -0,0 +1,31 @@
20 DEFINT A-Z
30 ARRAYSIZE = 10
40 DIM NUMBERS(ARRAYSIZE)
50 PRINT "Unsorted:";
60 FOR I = 1 TO ARRAYSIZE
70 NUMBERS(I) = INT(RND * 100) + 1
80 PRINT NUMBERS(I);
90 NEXT I
100 PRINT
110 REM ascending sort using Shell sort
120 GAP = INT(ARRAYSIZE / 2)
130 IF GAP = 0 THEN 270
140 FOR I = GAP + 1 TO ARRAYSIZE
150 J = I - GAP
160 WHILE J > 0
170 K = J + GAP
180 IF NUMBERS(J) <= NUMBERS(K) THEN J = 0: GOTO 220
190 TEMP = NUMBERS(J)
200 NUMBERS(J) = NUMBERS(K)
210 NUMBERS(K) = TEMP
220 J = J - GAP
230 WEND
240 NEXT I
250 GAP = INT(GAP / 2)
260 GOTO 130
270 PRINT "Sorted :";
280 FOR I = 1 TO ARRAYSIZE
290 PRINT NUMBERS(I);
300 NEXT
310 PRINT
320 END

View file

@ -0,0 +1,12 @@
import gleam/int
import gleam/io
import gleam/list
import gleam/string
pub fn main() {
[2, 1, 5, 3, 4]
|> list.sort(int.compare)
|> list.map(int.to_string)
|> string.join(" ")
|> io.println
}

View file

@ -0,0 +1 @@
34,12,23,56,1,129,4,2,73 | Sort-Object

View file

@ -0,0 +1,18 @@
-- 31 Mar 2026
include Setting
say 'SORT AN INTEGER ARRAY'
say version
say
-- Generate a demo stem, 100 items, random whole numbers
call MakeSt 'stem.','Z',100
-- Show original, 5 wide per item
call ShowSt 'stem.','random whole numbers',,5
-- Sort with (standard) numeric comparator (quicksort)
call SortSt 'stem.'
-- Show sorted
call ShowSt 'stem.','sorted!',,5
exit
-- MakeSt; ShowSt; SortSt
include Math

View file

@ -0,0 +1 @@
sort [2 4 3 1 2]

View file

@ -0,0 +1 @@
print sort nums: { 2 7 3 10 1 50 }

View file

@ -0,0 +1,46 @@
$constant ARRAY_SIZE = 10
var i, j, k, gap, temp = integer
dim integer numbers(ARRAY_SIZE)
comment
populate array with random integers in
range 1..100
end
print "Unsorted:";
for i=1 to ARRAY_SIZE
numbers(i) = int(rnd(1) * 100)+1)
print numbers(i);
next i
print
rem put in ascending order using Shell sort
gap = ARRAY_SIZE / 2
while gap > 0 do
begin
for i = gap+1 to ARRAY_SIZE
j = i - gap
while j > 0 do
begin
k = j + gap
if numbers(j) <= numbers(k) then
j = 0
else
begin
temp = numbers(j)
numbers(j) = numbers(k)
numbers(k) = temp
end
j = j - gap
end while
next i
gap = gap / 2
end while
rem show result
print "Sorted :";
for i = 1 to ARRAY_SIZE
print numbers(i);
next i
print
end