diff --git a/backend/idset.go b/backend/idset.go
index b34a69afb..de93f8754 100644
--- a/backend/idset.go
+++ b/backend/idset.go
@@ -1,5 +1,7 @@
 package backend
 
+import "sort"
+
 // IDSet is a set of IDs.
 type IDSet map[ID]struct{}
 
@@ -36,6 +38,8 @@ func (s IDSet) List() IDs {
 		list = append(list, id)
 	}
 
+	sort.Sort(list)
+
 	return list
 }