Sort posts by title, sort array by largest number [duplicate]

It might be easier if you rearranged how you’re going about this. Rather than putting a numerical value for the title, why not put it as a custom field. You can still show all your posts and orderby your custom field as a numerical value using meta_value_num. More info.

Here’s a topic on the WordPress Support forums for someone trying to accomplish the same thing: http://wordpress.org/support/topic/orderby-title-doesnt-sort-numbers-correctly?replies=38

Please note what user esmi says:

Can I point out that:

[…]

correct from a programming pov? Those “numbers” are actually strings –
not numeric integers.

PS — echo '<h1>$'. $ammount . '</h3>'; should be echo '<h1>$'. $ammount . '</h1>';