I am struggling to organize an array of objects based on a specific key (name). My goal is to have the data with uppercase letters appear first, but for some reason, it's displaying the lowercase data first. I've been using the lodash method "orderby" to achieve this. The initial array looks like this:
data = [
{
"id":"00000000-0000-0000-0000-000000100000",
"name":"DAS_Name_1",
"layer":"Raw",
"securityClass":"Green",
"domainName":null,
"domainId":null,
"isActive":true,
"isLocked":true,
"creationDate":"2019-10-09T23:12:34Z",
"createdByName":"DAS_Actor_User_Name_1",
"createdById":"User_Id_1"
},
{
"id":"00000000-0000-0000-0000-000000100009",
"name":"u_123",
"layer":"Standardized",
"securityClass":"Green",
"domainName":null,
"domainId":null,
"isActive":true,
"isLocked":true,
"creationDate":"2019-10-09T23:12:34Z",
"createdByName":"DAS_Actor_User_Name_10",
"createdById":"User_Id_10"
},
{
"id":"00000000-0000-0000-0000-000000100099",
"name":"Velvetica-123",
"layer":"Standardized",
"securityClass":"Red",
"domainName":null,
"domainId":null,
"isActive":false,
"isLocked":true,
"creationDate":"2019-10-09T23:12:34Z",
"createdByName":"DAS_Actor_User_Name_20",
"createdById":"User_Id_20"
},
{
"id":"00000000-0000-0000-0000-000000100100",
"name":"test_run-2",
"layer":"Data_Products",
"securityClass":"Green",
"domainName":null,
"domainId":null,
"isActive":true,
"isLocked":true,
"creationDate":"2019-10-09T23:12:34Z",
"createdByName":"DAS_Actor_User_Name_1",
"createdById":"User_Id_1"
}
]
When attempting to sort the data array utilizing lodash as follows:
data = _.orderBy(data, ["name"], ["desc"]);
The actual outcome turns out to be:
data = [
{
"id":"00000000-0000-0000-0000-000000100000",
"name":"test_run-2",
"layer":"Raw",
"securityClass":"Green",
"domainName":null,
"domainId":null,
"isActive":true,
"isLocked":true,
"creationDate":"2019-10-09T23:12:34Z",
"createdByName":"DAS_Actor_User_Name_1",
"createdById":"User_Id_1"
},
{
"id":"00000000-0000-0000-0000-000000100009",
"name":"u_123 ",
"layer":"Standardized",
"securityClass":"Green",
"domainName":null,
"domainId":null,
"isActive":true,
"isLocked":true,
"creationDate":"2019-10-09T23:12:34Z",
"createdByName":"DAS_Actor_User_Name_10",
"createdById":"User_Id_10"
},
{
"id":"00000000-0000-0000-0000-000000100099",
"name":"Velvetica-123",
"layer":"Standardized",
"securityClass":"Red",
"domainName":null,
"domainId":null,
"isActive":false,
"isLocked":true,
"creationDate":"2019-10-09T23:12:34Z",
"createdByName":"DAS_Actor_User_Name_20",
"createdById":"User_Id_20"
},
{
"id":"00000000-0000-0000-0000-000000100100",
"name":"DAS_Name_1 ",
"layer":"Data_Products",
"securityClass":"Green",
"domainName":null,
"domainId":null,
"isActive":true,
"isLocked":true,
"creationDate":"2019-10-09T23:12:34Z",
"createdByName":"DAS_Actor_User_Name_1",
"createdById":"User_Id_1"
}
]
This output is not what I expected. Any suggestions on how to resolve this issue?