diff --git a/modelling/src/afdb.cc b/modelling/src/afdb.cc
index 210146ac2b5fbcec97e2dc029e5fb3ef5a81245f..1548de1664ebb78747a0dd753ffe485eaf262059 100644
--- a/modelling/src/afdb.cc
+++ b/modelling/src/afdb.cc
@@ -118,6 +118,7 @@ void SeqToPentamerIndices(const String& seq, bool unique, std::vector<int>& indi
   }
   indices.resize(N-4);
   if(unique) {
+    std::sort(indices.begin(), indices.end());
     auto last = std::unique(indices.begin(), indices.end());
     indices.erase(last, indices.end());
   }