[SalesForce] Sort related list with null values last

Is it possible to have a related list sorted by a specific column while displaying the empty values last? By default, these are shown at the top of the list.

The field i want to sort after has the type Number(13,5), let's call it FieldToSortAfter__c. In SOQL i can do:

SELECT Field1__c, Field2__c
FROM MyObject__c
ORDER BY FieldToSortAfter__c NULLS LAST

I didn't find a counterpart for sorting related lists, though. I have already tried creating a formula field Order__c with this content:

IF( ISNULL(FieldToSortAfter__c),(
  9999999999999.99999
),(
  FieldToSortAfter__c
))

But when i want to use this to sort the related list, i have to display the column which looks ugly. Any suggestions on how to improve this?

Maybe one could build a VF page that mimicks the related list but it would need to have all the components (buttons, help link) that standard lists have. Another idea would be to use some Javascript to sort the rows on the client side. Is this possible while still using the standard layout?

Best Answer

Try to use the following formula of type "Text":

IF(ISBLANK(FieldToSortAfter__c),  IMAGE('/s.gif',' ') , ' ' + TEXT(FieldToSortAfter__c))

The formula checks for the blank value and if it is then it puts a transparent image so nobody can see it on the page. But if the field has a value then just puts a space before it so the sorter "thinks" that this value is "smaller" that the image :)

Here is my result:

enter image description here