WJ wrote:
> Barry Margolin wrote:
>
> > > I have a list with contains property lists with the properties:
> > > :date
> > > :personal
> > > :utilities
> > > :dogs
> >
> > > This is the sequence I would prefer the properties to be in the list.
> > > When new lists are added, this is the sequence, but for old lists this
> > > is not the case. Is there a way to rearrange the properties in the
> > > property lists in my list?
> >
> > > The reason I want this, is that the saved list is more human readable.
> >
> > (defun canonicalist-plist (plist)
> > (flet ((get-prop (prop)
> > (list prop (getf plist prop))))
> > (mapcan #'get-prop '(:date :personal :utilities :dogs))))
> >
> > This assumes there are no other properties in the plist that you need to
> > retain.
Instead of CL, tCL.
namespace path {tcl::mathop tcl::mathfunc}
proc compare args {
- {*}[lmap x $args {lsearch {:date :personal :utilities :dogs} $x}]}
proc norm_plist plist {lsort -stride 2 -command compare $plist}
norm_plist {:dogs 2 :date "2012-08-09" :personal foo :utilities 3}
==>
:date 2012-08-09 :personal foo :utilities 3 :dogs 2