Serializing an array

Richard Suchenwirth 2006-01-18 - Playing with htext, it became obvious to me that with added editing and saving functions, it could grow in the direction of a minimal Wiki, say on a PocketPC. So I wrote this array pretty-printer, with sorted keys and newlines thrown in:

 proc arr'dump {_arr file} {
   upvar 1 $_arr arr
   set f [open $file w]
   puts $f "array set $_arr \{"
   foreach key [lsort [array names arr]] {
      puts $f [list $key $arr($key)]
   }
   puts $f "\}"
   close $f
 }

The format is such that source is sufficient for loading such a file.