diff --git a/src/space.c b/src/space.c
index 9a255e38ca9afb9c93833d03bbb8c088bdbefb7b..9cdd24ce7ef6184d10d3baec3a19859bef614443 100644
--- a/src/space.c
+++ b/src/space.c
@@ -486,8 +486,8 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
 
 #endif
 
-  /* Sort the parts according to their cells. */
-  space_parts_sort(s, ind, nr_gparts, 0, s->nr_cells - 1, verbose);
+  /* Sort the gparts according to their cells. */
+  space_gparts_sort(s, ind, nr_gparts, 0, s->nr_cells - 1, verbose);
 
   /* Re-link the parts. */
   for (int k = 0; k < nr_gparts; k++)