Skip to content

Commit

Permalink
Merge pull request #44 from eugenethered/master
Browse files Browse the repository at this point in the history
fix: when collection does not have property, should still sort
  • Loading branch information
samuk190 authored Jun 6, 2024
2 parents 55d61a7 + 795f8ba commit 708328b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions localbase/api/actions/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ export default function get(options = { keys: false }) {
logMessage += `, ordered by "${ orderByProperty }"`
if (!options.keys) {
collection.sort((a, b) => {
if (!a.hasOwnProperty(orderByProperty) || !b.hasOwnProperty(orderByProperty)) return 0
return a[orderByProperty].toString().localeCompare(b[orderByProperty].toString())
})
}
else {
collection.sort((a, b) => {
if (!a.hasOwnProperty(orderByProperty) || !b.hasOwnProperty(orderByProperty)) return 0
return a.data[orderByProperty].toString().localeCompare(b.data[orderByProperty].toString())
})
}
Expand Down

0 comments on commit 708328b

Please sign in to comment.