diff --git a/src/Query/Builder.php b/src/Query/Builder.php
index <HASH>..<HASH> 100644
--- a/src/Query/Builder.php
+++ b/src/Query/Builder.php
@@ -234,9 +234,7 @@ class Builder
         }
 
         if ($results) {
-            if (!empty($this->sortByField)) {
-                $this->connection->sort($results, $this->sortByField);
-            }
+            $this->processSort($results);
 
             return $this->processResults($results);
         }
@@ -266,6 +264,8 @@ class Builder
             $results = $this->connection->search($this->getDn(), $this->getQuery(), $this->getSelects());
 
             if ($results) {
+                $this->processSort($results);
+
                 $this->connection->controlPagedResultResponse($results, $cookie);
 
                 $pages[] = $results;
@@ -835,6 +835,20 @@ class Builder
     }
 
     /**
+     * Sorts LDAP search results.
+     *
+     * @param $results
+     *
+     * @return void
+     */
+    private function processSort($results)
+    {
+        if (!empty($this->sortByField)) {
+            $this->connection->sort($results, $this->sortByField);
+        }
+    }
+
+    /**
      * Retrieves an operator from the available operators.
      *
      * Throws an AdldapException if no operator is found.
Fix sorting with paginate

- Added process sort method to be used by the `query()` and `paginate()`
method

Fixes #<I>