let count (data : data list) = 
   (* get an array where the nth entry equals the list split according to the nth attribute*)
   let sorter i x = x.(i) in
   let num_attribs = Array.length (List.hd data) in
   let sorted = Array.init num_attribs (fun i -> sort (sorter i) data) in
   (* replace the lists with tupels of their attribute and their lengths *)
   let flatten i dat  = List.map (fun x -> ((List.hd x).(i),List.length x)) dat in
   Array.mapi flatten sorted