Windows XP
python 2.3
How do you sort data alphabetically in the grid column.
In one of the previous post i found a link
[HTML]http://dotnetjunkies.com/Tutorial/E169C6D4-D335-4D2B-AE3F-918EE3161815.dcik[/HTML]
its not in python so can anyone please explain the logic behind it.
it was (fairly)easy to sort the datagrid column if the column contained just numbers.
( double click event on a particular column label)
Expand|Select|Wrap|Line Numbers
- counter = 1
- Number_of_rows_Grid1 = self.grid1.GetNumberRows()
- self.grid1.InsertRows(pos=Number_of_rows_Grid1, numRows=1)
- for rows1 in range (0, Number_of_rows_Grid1-1):
- P1 = self.grid1.GetCellValue(rows1, clicked_column_number)
- if (P1):
- P1 = float(P1)
- else:
- P1 = 0.00
- for rows2 in range (counter, Number_of_rows_Grid1-1):
- P2 = self.grid1.GetCellValue(rows2, clicked_column_number)
- if (P2):
- P2 = float(P2)
- else:
- P2 = 0.00
- if (P2<P1):
- for col in range (0, 10):
- self.grid1.SetCellValue(Number_of_rows_Grid1, col, self.grid1.GetCellValue(rows1, col))
- self.grid1.SetCellValue(rows1, col, self.grid1.GetCellValue(rows2, col))
- self.grid1.SetCellValue(rows2, col, self.grid1.GetCellValue(Number_of_rows_Grid1, col))
- P1 = P2
- counter = counter + 1
- self.grid1.DeleteRows(pos=Number_of_rows_Grid1, numRows=1)