'Sort a :class:`Dataset` by a specific column, given string (for
header) or integer (for column index). The order can be reversed by
setting ``reverse`` to ``True``.
Returns a new :class:`Dataset` instance where columns have been
sorted.'

def sort(self, col, reverse=False):

    if (isinstance(col, str) or isinstance(col, unicode)):
        if (not self.headers):
            raise HeadersNeeded
        _sorted = sorted(self.dict, key=itemgetter(col), reverse=reverse)
        _dset = Dataset(headers=self.headers, title=self.title)
        for item in _sorted:
            row = [item[key] for key in self.headers]
            _dset.append(row=row)
    else:
        if self.headers:
            col = self.headers[col]
        _sorted = sorted(self.dict, key=itemgetter(col), reverse=reverse)
        _dset = Dataset(headers=self.headers, title=self.title)
        for item in _sorted:
            if self.headers:
                row = [item[key] for key in self.headers]
            else:
                row = item
            _dset.append(row=row)
    return _dset
