oderid sort not work correclty in number more than 1000 in commerce_orders views I look at the commerce_orders views, and I see some strange there, when I set sort record according by orderID it not work correctly for number more than 1000 ,it seems that only 3 first digit consider in sort, Is this a bug in views? 
appreciate any help



and query is :

SELECT commerce_order.order_number AS commerce_order_order_number, commerce_order.order_id AS order_id, commerce_order.uid AS commerce_order_uid, commerce_order.created AS commerce_order_created, commerce_customer_profile_field_data_commerce_customer_billing.profile_id AS commerce_customer_profile_field_data_commerce_customer_billi, users_commerce_order.name AS users_commerce_order_name, users_commerce_order.uid AS users_commerce_order_uid, commerce_order.status AS commerce_order_status, 'commerce_customer_profile' AS field_data_commerce_customer_address_commerce_customer_profi, 'commerce_order' AS field_data_commerce_order_total_commerce_order_entity_type
FROM 
{commerce_order} commerce_order
LEFT JOIN {users} users_commerce_order ON commerce_order.uid = users_commerce_order.uid
LEFT JOIN {field_data_commerce_customer_billing} field_data_commerce_customer_billing ON commerce_order.order_id = field_data_commerce_customer_billing.entity_id AND (field_data_commerce_customer_billing.entity_type = 'commerce_order' AND field_data_commerce_customer_billing.deleted = '0')
LEFT JOIN {commerce_customer_profile} commerce_customer_profile_field_data_commerce_customer_billing ON field_data_commerce_customer_billing.commerce_customer_billing_profile_id = commerce_customer_profile_field_data_commerce_customer_billing.profile_id
WHERE (( (commerce_order.status NOT IN  ('cart', 'checkout_checkout', 'checkout_shipping', 'checkout_review', 'checkout_payment', 'checkout_complete')) ))
ORDER BY commerce_order_order_number DESC
LIMIT 50 OFFSET 0
As you can see in commerce_order_schema, order number is not a number, it's a string:

'order_number' =&gt; array(
    'description' =&gt; 'The order number displayed to the customer.', 
    'type' =&gt; 'varchar', 
    'length' =&gt; 255, 
    'not null' =&gt; FALSE,
  ),


This means that your view works as designed, sorting this text field that accidentally contains numbers alphabetically. Which, again accidentally, gave you illusion of numeric sort when numbers was in [100-999] range.

If you need something that's guaranteed to be numeric and ordered the way orders was placed, use either order_id ('type' =&gt; 'serial') or created ('type' =&gt; 'int').