Fixed sorting

Moved sorting code from ../index.blade.php