#NEWLINE# def order_by( self , * colnames ) : #NEWLINE# #INDENT# '\n        Sets the column(s) to be used for ordering\n\n        Default order is ascending, prepend a \'-\' to any column name for descending\n\n        *Note: column names must be a clustering key*\n\n        .. code-block:: python\n\n            from uuid import uuid1,uuid4\n\n            class Comment(Model):\n                photo_id = UUID(primary_key=True)\n                comment_id = TimeUUID(primary_key=True, default=uuid1) # second primary key component is a clustering key\n                comment = Text()\n\n            sync_table(Comment)\n\n            u = uuid4()\n            for x in range(5):\n                Comment.create(photo_id=u, comment="test %d" % x)\n\n            print("Normal")\n            for comment in Comment.objects(photo_id=u):\n                print comment.comment_id\n\n            print("Reversed")\n            for comment in Comment.objects(photo_id=u).order_by("-comment_id"):\n                print comment.comment_id\n        ' #NEWLINE# if ( len ( colnames ) == 0 ) : #NEWLINE# #INDENT# clone = copy . deepcopy ( self ) #NEWLINE# clone . _order = [ ] #NEWLINE# return clone #NEWLINE# #UNINDENT# conditions = [ ] #NEWLINE# for colname in colnames : #NEWLINE# #INDENT# conditions . append ( '"{0}" {1}' . format ( * self . _get_ordering_condition ( colname ) ) ) #NEWLINE# #UNINDENT# clone = copy . deepcopy ( self ) #NEWLINE# clone . _order . extend ( conditions ) #NEWLINE# return clone