              (offset, reverse, current_position) = (0, False, '')
          else:
              self.cursor = decode_cursor(encoded)
              (offset, reverse, current_position) = self.cursor
              # TODO: Invalid cursors should 404
  
          # Cursor pagination always enforces an ordering.
          if reverse:
              queryset = queryset.order_by('-' + self.ordering)
          else:
 
</s> remove         compare = self.next_position
 </s> add         if self.cursor and self.cursor.reverse and self.cursor.offset != 0:
            # If we're reversing direction and we have an offset cursor
            # then we cannot use the first position we find as a marker.
            compare = self._get_position_from_instance(self.page[-1], self.ordering)
        else:
            compare = self.next_position </s> remove         compare = self.previous_position
 </s> add         if self.cursor and not self.cursor.reverse and self.cursor.offset != 0:
            # If we're reversing direction and we have an offset cursor
            # then we cannot use the first position we find as a marker.
            compare = self._get_position_from_instance(self.page[0], self.ordering)
        else:
            compare = self.previous_position </s> remove             self.page = reversed(self.page)
 </s> add             self.page = list(reversed(self.page))
              (offset, reverse, current_position) = (0, False, '')
          else:
              self.cursor = decode_cursor(encoded)
              (offset, reverse, current_position) = self.cursor

  
          # Cursor pagination always enforces an ordering.
          if reverse:
              queryset = queryset.order_by('-' + self.ordering)
          else:
keep keep keep keep replace keep keep keep keep keep
 Tidy up cursor tests and make more comprehensive 
rest_framework/pagination.py