def sort_by_column(self, col, reverse=False):
        """ Sort model data by the column indexed by col. """

        # first check to see if we allow sorts by column
        if not self.allow_column_sort:
            return

        # see if a sorter is specified for this column
        try:
            column = self._auto_columns[col]
            name = self.__get_column_name(col)
            # by default we use cmp to sort on the traits
            sorter = cmp
            if isinstance(column, TraitGridColumn) and \
                   column.sorter is not None:
                sorter = column.sorter
        except __HOLE__:
            return

        # now sort the data appropriately
        def sort_function(a, b):
            if hasattr(a, name):
                a_trait = getattr(a, name)
            else:
                a_trait = None

            if hasattr(b, name):
                b_trait = getattr(b, name)
            else:
                b_trait = None

            return sorter(a_trait, b_trait)

        self.data.sort(sort_function)

        if reverse:
            self.data.reverse()

        # now fire an event to tell the grid we're sorted
        print 'firing sort event'
        self.column_sorted = GridSortEvent(index = col, reversed = reverse)

        return
dataset/ETHPy150Open enthought/pyface/pyface/ui/wx/grid/trait_grid_model.py/TraitGridModel.sort_by_column