Write a component that sorts a hardcoded array of objects by a nested property (e.g., person.address.zipcode) and displays the sorted array.
HardProblem Statement
Write a component that sorts a hardcoded array of objects by a nested property (e.g., person.address.zipcode) and displays the sorted array.
Sample Input
Array:
[
{ "name": "Alice", "address": { "zipcode": 12345 } },
{ "name": "Bob", "address": { "zipcode": 54321 } },
{ "name": "Charlie", "address": { "zipcode": 11111 } }
]Sample Output
Sorted Array: [{ name: 'Charlie' }, { name: 'Alice' }, { name: 'Bob' }]Limits
Time: 2s · Memory: 256 MB
Code Editor
Log in to submit00:00
Try your code in this preview. Submit marks it done.
import React from "react"; const SortByNestedProperty = () => { return ( <div> {/* Display sorted array */} </div> ); }; export default SortByNestedProperty;