Skip to content

Instantly share code, notes, and snippets.

View gaozhidf's full-sized avatar
💭
I may be slow to respond.

里丰 gaozhidf

💭
I may be slow to respond.
View GitHub Profile
ids = [9, 8, 1, 2, 7, 3]
results = Model.objects.filter(id__in=ids).extra(
select={'manual': 'FIELD(id,%s)' % ','.join(map(str, ids))},
order_by=['manual']
)
@gaozhidf
gaozhidf / tree.py
Created March 22, 2018 16:11 — forked from anonymous/tree.py
class Node(object):
def __init__(self, val, left=None, right=None):
self.val = val
self.left = left
self.right = right
def max_of_tree(root):
if not root:
return 0