Let the array objects output in the specified order

implement a method fun (tt,arr) that makes the array object arr, output in the specified order tt;

   let tt={
        city:"",
        age:"",
        name:""
    }


    let arr=[
        {
            name: "xiaoming",
            age: 15,
            city:"sz"
        },
        {
            name: "xiaoming",
            age: 16,
            city:"sz"
        }
    ]

final result:

   let arr2=[
        {
            city:"sz",
             age: 15,
            name: "xiaoming",
           
        },
         {
            city:"sz",
             age: 16,
            name: "xiaoming",
           
        }
    ]

Jun.09,2021

11:35:10 on September 11, 2018, this is really the last version of the answer.
is basically the initial answer. Just looking for some information.
objects are unordered, and the order varies from browser to browser. Want to swap arrays with ordered arrays

SF search for things about traversing the order of objects
Javascript objects (continuously updated)
SJ9011: The order in which for-in statements traverse object attributes in Chrome Opera is different from the definition

< hr >

there is something wrong with the test case [artificial embarrassing face]. Change it to disorder and come out in order. The letters don't seem to have changed. I'll check the information again

.

clipboard.png


201891111:09:36


chromett
FF




clipboard.png


this doesn't make any sense. There is no sequence relationship between the keys of an object


object is inherently unordered, can't you just use key to take a value?


  

your tt is an ordinary object, and there is no stable order of objects in javascript in theory.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea2735-1bde.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea2735-1bde.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?