Fixed bug in cursor.count() when cursor is ordered