`*-----------------------------------*`

`*           >>>Pico 2.0<<<          *`

`*         Wolfgang De Meuter        *`

`*  VUB Programming Technology Lab   *`

`*               ©2004               *`

`*-----------------------------------*`

`*  Generic Bubble Sort Routine      *`

`*-----------------------------------*`

{ bubblesort(t, l << r):: {

    swap(i,j):{

      temp: t[i];

      t[i]:=t[j];

      t[j]:=temp };

    k: size(t);

    sorted: false;

    while((k>0) & !sorted,{

      sorted:=true;

      for(j:1, j<k, j:=j+1,

        if(t[j+1] << t[j],

          { swap(j,j+1);

            sorted:=false },

          void));

      k:= k-1 } );

    t };

  `* SAMPLE CODE *`

  Person(nam,age):[nam,age];

  display(bubblesort([Person("wolfgang",34),Person("isabel",30)], l[2] > r[2]))

}