Fix Product Sorting Issues in Magento 1.8

magento-1.8sorting

I have created product attribute named Custom Sort Catalog >> Attributes >> Manage Attributes

Catalog Input Type for Store Owner as Text Field
Input Validation for Store Owner as Decimal

and i'm using this attribute as default sort for my products
Catalog >> Manage Categories
in category edit page under Display Settings i have set Default Product Listing Sort By as my attribute Custom Sort

but the issue is magento sorts the products in following way
1
11
2
3

I would like to sort products in following way
1
2
3
11

Please guide me how to achieve this

Best Answer

Actually the sorting works properly. If your attribute has the type "text" the sorting will work on strings.
So from the strings point of view 11 < 2.
You need to have the attribute as decimal.
The Input Validation for Store Owner fields means just a simple validation. It does not mean that the attribute type will be decimal.
The value is still saved as varchar.

See this on how to create a product attribute programatically.

If you want to create the attribute from the UI and have the type 'decimal', I'm not sure what type you have to choose. I think price but not sure.