sort and shuffle for rails3