sorting workqueue elements by timestamp

This should fix issue #4911