[32eb06]: Tests / quicksort.sis  Maximize  Restore  History

Download this file

29 lines (22 with data), 523 Bytes

define	Main

type Info = array[ integer ]

function Main (	Data : Info returns Info )

    function Split (Data : Info  returns Info, Info, Info )
	for E in Data
	returns	array of E when E < Data[ 1 ]
		array of E when E = Data[ 1 ]
		array of E when E > Data[ 1 ]
	end for
    end function

    % routine body
    %

    if array_size( Data ) > 2 then
       let
          L, Middle, R := Split( Data )
       in
	  Main( L ) || Middle || Main( R )
       end let
    else
       Data
    end if

end function % quicksort

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks