can anyone tell me how use bubble sorting algorithm to sort data dataGridView.
below shown my code which i use to add data to grid.
below shown my code which i use to add data to grid.

Code:
List<STUDENT> student_list = new List<STUDENT>();
private void btnAddToGroup_Click(object sender, EventArgs e)
{
if (dataGridView1.SelectedRows.Count > 4 || dataGridView1.SelectedRows.Count < 2)
{
MessageBox.Show( "The Selected row count should be < 4 or > 2,\n Please try again");
}
else
{
//gridDesignGroup();
for (int i = 0; i < dataGridView1.SelectedRows.Count; i++)
{
STUDENT stuObj = new STUDENT();
stuObj.groupID = txtGID.Text;
stuObj.stuId = dataGridView1.SelectedRows[i].Cells[0].Value.ToString();
stuObj.stuFirstName = dataGridView1.SelectedRows[i].Cells[1].Value.ToString();
stuObj.stuLastName = dataGridView1.SelectedRows[i].Cells[2].Value.ToString();
stuObj.stuEmail = dataGridView1.SelectedRows[i].Cells[3].Value.ToString();
student_list.Add(stuObj);
BindingSource bind = new BindingSource();
bind.DataSource = student_list;
dataGridView2.DataSource = bind;
}
foreach (DataGridViewRow r in dataGridView1.SelectedRows)
{
dataGridView1.Rows.Remove(r);
}
}
}

