bogosort


See On Github

Data

Contributor

Generic placeholder thumbnail

by sebasguts

in gap

Source Code


bogosort := function( list )
  
  while not IsSortedList( list ) do
    
    Shuffle( list );
    
  od;
  
  return list;
  
end;

Read( "bogosort.gi" );

list := List( [ 1 .. 5 ], i -> Random( [ 1 .. 30 ] ) );

list := bogosort( list );

IsSortedList( list );