i needed to list all VMs on given KVM server and sort them by amount of RAM allocated to each.
(for vm in $(virsh list --all --name|grep -v -e '^$'); do echo -n "$vm " ; virsh dumpxml "$vm" | grep "memory unit"|awk -F '(>|<)' '{print $3}'; done) | sort -k2 -n
ugly but does the trick.