lodash orderby with null and real values not ordering correctly

后端 未结 6 711

I have an Angular 2 typescript application that is using lodash for various things.

I have an array of objects that I am ordering using a property in the object...

6条回答
  •  囚心锁ツ
    2021-01-07 23:03

    This worked for me

    orders = [{id : "1", name : "test"}, {id : "1"}];
    sortBy = ["id", "name"];
    orderby(
                orders,
                sortBy.map(s => {
                    return (r: any) => {
                        return r[s] ? r[s] : "";
                    };
                })),
            );
    

提交回复
热议问题