#2760 - DynamoDB - Ensure proper ordering for Numeric sort keys
This commit is contained in:
parent
60c98ca836
commit
67c7fce85e
2 changed files with 64 additions and 1 deletions
|
|
@ -981,8 +981,13 @@ class Table(BaseModel):
|
|||
if index_name:
|
||||
|
||||
if index_range_key:
|
||||
|
||||
# Convert to float if necessary to ensure proper ordering
|
||||
def conv(x):
|
||||
return float(x.value) if x.type == "N" else x.value
|
||||
|
||||
results.sort(
|
||||
key=lambda item: item.attrs[index_range_key["AttributeName"]].value
|
||||
key=lambda item: conv(item.attrs[index_range_key["AttributeName"]])
|
||||
if item.attrs.get(index_range_key["AttributeName"])
|
||||
else None
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue