View sorting programmatically
The problem was hook_views_pre_render, for some reason the markup is already render at this stage (weird..),  when I used the same code in hook_views_post_execute it worked perfectly.