如何使用不同的对象数组对对象数组进行排序?

时间:2019-09-28 18:01:36

标签: javascript es6-class

我在尝试获取一组对象以不同顺序显示时遇到问题。我们应该让输出的显示名称按索引,名字,姓氏和年龄进行排序。当我运行代码时,我只会看到一次显示名称。我已经附上了欲望输出的图片,我有些困惑和受阻。这是我到目前为止的内容:

    + mysqladmin -u root password supersecretpassword create database '"wp_$sitealias"'
    mysqladmin: CREATE DATABASE failed; error: 'Can't create database 'database'; database exists'
    + mysqladmin -u root password supersecretpassword CREATE USER '"$sitealias"@localhost' IDENTIFIED BY '$MOREF'
    mysqladmin: CREATE DATABASE failed; error: 'Can't create database 'USER'; database exists'
    + mysqladmin -u root password supersecretpassword grant all privileges ON 'wp_uuujjud.*' TO '$sitealias@localhost'
    mysqladmin: Unknown command: 'grant'
    + FLUSH PRIVILEGES
    hello.sh: line 37: FLUSH: command not found
    + quit
    hello.sh: line 38: quit: command not found

desire output

1 个答案:

答案 0 :(得分:1)

您只是错过了这些行以获取所有不同的排序吗?

printObject(allNames, "first", "By first name");
printObject(allNames, "last", "By last name");
printObject(allNames, null, "By index");

跟随printObject(allNames, "age", "Message");吗?

(我将更改为printObject(allNames, "age", "By age");