codeigniter order by

$this->db->select('*');
$this->db->from('your_table_name');
$this->db->order_by('column_name', 'asc'); // Replace 'column_name' with the actual column name you want to order by
$query = $this->db->get();
$result = $query->result();

Explanation:

  1. $this->db->select('*');: Specifies that all columns should be selected in the query.

  2. $this->db->from('your_table_name');: Specifies the table from which to retrieve the data, replace 'your_table_name' with the actual name of your table.

  3. $this->db->order_by('column_name', 'asc');: Specifies the order in which the result should be sorted. Replace 'column_name' with the actual column name you want to use for ordering. 'asc' stands for ascending order, you can use 'desc' for descending order.

  4. $query = $this->db->get();: Executes the query and stores the result in the $query variable.

  5. $result = $query->result();: Fetches the result of the query and stores it in the $result variable. The result can be iterated through as an array of objects.