GIML: Tutorial Six: More Hints

fun sort (f:'a -> real) nil = nil
|   sort f (h::t) = let
  fun insert x nil    = [x]
  |   insert x (h::t) = if f x > f h then x::h::t else
					  h::insert x t
in insert h (sort f t) end;
This particular version of sort allows us to specify the quantity to sort on. The quantity must be a real number - for example population or GDP.

Enter the following lines in sequence

sort area europe;
hd it;
name it;
All this might be done in one go as follows:
val bigArea = name(hd(sort area europe));