0

Say I have a function:

function sorter(a,b)

And it has a rule for defining if row value a is "bigger" than row value b (so returns 1 if a>b and -1 if row value a is "smaller" than bigger than row value b.

Can I sort the results by this function?

An example could be the "log" math function function (bad example because it's monotonic increasing), with a and b being positive integers.

The only way I can think of doing this is by simply getting all the rows matching my query and then looping through them one by one and using my sorter function to sort them. The data set has returned > 30k rows in my example queries and I am estimating up to 100k rows could be returned in the worst case scenario. So I would prefer not to loop through the results (this is for a web application and needs to respond in realtime).

Edit: I should add, the sorter function is time dependent and features variables that change value over time. So precomputing is not an option.

1 Answer 1

2

When querying DynamoDB the records will be sorted by the range key and you can decide to sort ascending or descending. It is not possible to specify any other sort order with DynamoDB.

Sorting records by any other method would need to be performed by your application code.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.