简体   繁体   中英

How do i sort dataGridView data using bubble sort or any other sorting algorithm in C#?

This is the populated data in gridview Image That Shows The DataGridView

Now, when i click the button2 the values should be sorted according to total earing from highest to lowest. How do i do that?

You can call

yourdatagridview.Sort(yourdatagridview.Columns["name_of_total_earning_column_here"], ListSortDirection.Descending);

..footnote that the underlying data will need to be numeric for it to work "properly". If total earning is a string you'll see 20, 2, 11, 10, 1 etc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM