order( [ X | [ X | Z ] ], [ X | [ X | Z ] ] ).
order( [ X | [ Y | Z ] ], [ X | [ Y | Z ] ] ):-
	less( X, Y ).
order( [ X | [ Y | Z ] ], [ Y | [ X | Z ] ] ):-
	less( Y, X ).
	
bubble( [], [] ).
bubble( [ X ], [ X ] ).
bubble( [ X | Y ], W ):- 
	bubble( Y, [ U | V ] ), 
	order( [ X | [ U | V ] ], W ).

sort( [], [] ).
sort( Z, [ X | W ] ):-
	bubble( Z, [ X | Y ] ),
	sort( Y, W ).
