sort by value javascript array code example Example: javascript sort by id elems.sort((a, b) => a.id - b.id);