mirror of
https://gitlab.aachen.ccc.de/inventory/in.git
synced 2024-11-25 16:53:59 +01:00
fix bug in sorting when item type is null
This commit is contained in:
parent
93d6063c52
commit
160c12561c
1 changed files with 1 additions and 1 deletions
2
main.py
2
main.py
|
@ -31,7 +31,7 @@ def _set_sqlite_pragma(conn, _):
|
|||
@app.get("/api/items", response_model=dict[str, Item])
|
||||
async def list_items(db: Session = Depends(get_db)):
|
||||
# sort by type, id (natural)
|
||||
natsort = lambda s: (s.type, [int(t) if t.isdigit() else t.lower() for t in re.split('(\d+)', s.id)])
|
||||
natsort = lambda s: (s.type or '', [int(t) if t.isdigit() else t.lower() for t in re.split('(\d+)', s.id)])
|
||||
items = crud.get_items(db)
|
||||
items = sorted(items, key=natsort)
|
||||
return {i.id:i for i in items}
|
||||
|
|
Loading…
Reference in a new issue