How To Sort The View's Result Based On The Largest Value

I have an application which is look like this image :

3584

Screenshot-1.png

in the action column, there are up and down arrows, that will be used for arranging / ordering the position of my articles. that arrows linked to this function in KBController :


public function moveup($id){

        $model = $this->loadModel($id);

        $model->KBORDER += 10;

        

        if ($model->save())

            $this->redirect(array('admin'));

    }

    

    public function movedown($id){

        $model = $this->loadModel($id);

        $model->KBORDER -= 10;

        

        if ($model->save())

            $this->redirect(array('admin'));    

}

my question is, how to order / sort the view’s result based on the largest value of the KBORDER? for example, like this image :

3585

Screenshot-2.png

so, not only sort the result but when the result have the largest value, the up arrow will be unavailable. and when the result have the smallest value, the down arrow will be unavailable too. and my second question is, how to make this arrow will be available and unavailable based on it’s position?

thanks for helping me :D