def sort(self, key, reverse=False):
        """
        Sort the current list of items using the key function ``key``. If
        ``reverse`` is true the sort order is reversed.
        """
        row = self.GetGridCursorRow()
        col = self.GetGridCursorCol()
        curitem = self.table.items[row] # Remember where the cursor is now
        # Sort items
        def realkey(item):
            try:
                return key(item)
            except (KeyboardInterrupt, __HOLE__):
                raise
            except Exception:
                return None
        try:
            self.table.items = ipipe.deque(sorted(self.table.items, key=realkey, reverse=reverse))
        except TypeError as exc:
            self.error_output("Exception encountered: %s" % exc)
            return
        # Find out where the object under the cursor went
        for (i, item) in enumerate(self.table.items):
            if item is curitem:
                self.SetGridCursor(i,col)
                self.MakeCellVisible(i,col)
                self.Refresh()
dataset/ETHPy150Open ipython/ipython-py3k/IPython/deathrow/igrid.py/IGridGrid.sort