Opened 7 years ago

Closed 7 years ago

#16065 closed defect (duplicate)

dojo.store.Memory not sorting properly when data contains nulls

Reported by: kevindavis Owned by: Kris Zyp
Priority: undecided Milestone: tbd
Component: Data Version: 1.7.2
Keywords: Cc:
Blocked By: Blocking:

Description

In this example code when null values exist in the data the sort on a Memory data store does not work properly. (it sorts differently in different browsers but not in the correct order)

<html> <head> <script type="text/javascript" src="js/dojo-release-1.7.2-src/dojo/dojo.js" djConfig="isDebug: false, parseOnLoad: true"></script> <script type="text/javascript"> var store; var store2; require(dojo/store/Memory?, function(Memory){

var someData = [

{id:1, name:"One"},

{id:2, name:"Two"}, {id:3, name:"Three"}, {id:8, name:'Eight'}, {id:4, name:"Four"}, {id:5, name:"Five"}, {id:6, name:"Six"}, {id:7, name:"Seven"}, {id:0, name:'Zero'}

]; store = new Memory({data: someData});

console.debug(store.query({}, {sort: [{attribute: "name"}]})) Returns query results and sort by name

var someData2 = [

{id:1, name:"One"}, {id:2, name:"Two"}, {id:3, name:"Three"}, {id:8, name:null}, {id:4, name:"Four"}, {id:5, name:"Five"}, {id:6, name:"Six"}, {id:7, name:"Seven"}, {id:0, name:null}

]; store2 = new Memory({data: someData2});

console.debug(store2.query({}, {sort: [{attribute: "name"}]})) Returns results but they are not sorted correctly

}); </script> </head> <body> </body> </html>

Chrome output First List: Eight Five Four One Seven Six Three Two Zero Second List: One Three Two null Five Four Seven Six null

Safari output First List: Eight Five Four One Seven Six Three Two Zero Second List: Five Four Seven Six null null One Three Two

Change History (1)

comment:1 Changed 7 years ago by Kris Zyp

Resolution: duplicate
Status: newclosed

Duplicate of #15515.

Note: See TracTickets for help on using tickets.