Ordering is usually done in data layer(i.e in a db query). Don’t know much about Joomla. If you need to get it done with Joomla, it’s better to get help from the community.
There might be some better way that comes designer friendly: Template Engine.