The foreach currently only sorts based on the @count for aggregates. It would be very nice to allow ordering based on the the other aggregate operators. latencytap make use of a sort based on the @max times to show what things have the largest latencies.
Frank and I discussed this a long time ago, but I guess we then forgot. Here it is in the mailing list archives (multiple links because the threading broke). sort a foreach on a stat value? jistone: http://sourceware.org/ml/systemtap/2005-q4/msg00550.html fche: http://sourceware.org/ml/systemtap/2006-q1/msg00113.html jistone: http://sourceware.org/ml/systemtap/2006-q1/msg00142.html fche: http://sourceware.org/ml/systemtap/2006-q1/msg00175.html jistone: http://sourceware.org/ml/systemtap/2006-q1/msg00219.html
Certainly things could be implemented with another foreach to sort things and can do that with latencytap. This was something to simplify the user scripts and avoid some of overhead of having two foreach loops.
commit fd5689dc et al.