-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsortingByCharacter.js
More file actions
58 lines (54 loc) · 2.04 KB
/
Copy pathsortingByCharacter.js
File metadata and controls
58 lines (54 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
var objs = [
{
first_nom: '5.1.Laszlo', last_nom: [{ first_nom: '5.1.Laszlo', last_nom: 'Jamf' },
{ first_nom: '5.3Pig', last_nom: 'Bodine' },
{ first_nom: 'Pirate', last_nom: 'Prentice' },
{ first_nom: '5.2 Pirate', last_nom: 'Prentice' },
{ first_nom: 'สัญญาจ้าง', last_nom: 'Prentice' }]
},
{
first_nom: '5.3Pig', last_nom: [{ first_nom: '5.1.Laszlo', last_nom: 'Jamf' },
{ first_nom: '5.3Pig', last_nom: 'Bodine' },
{ first_nom: 'Pirate', last_nom: 'Prentice' },
{ first_nom: '5.2 Pirate', last_nom: 'Prentice' },
{ first_nom: 'สัญญาจ้าง', last_nom: 'Prentice' }]
},
{
first_nom: 'Pirate', last_nom: [{ first_nom: '5.1.Laszlo', last_nom: 'Jamf' },
{ first_nom: '5.3Pig', last_nom: 'Bodine' },
{ first_nom: 'Pirate', last_nom: 'Prentice' },
{ first_nom: '5.2 Pirate', last_nom: 'Prentice' },
{ first_nom: 'สัญญาจ้าง', last_nom: 'Prentice' }]
},
{
first_nom: '5.2 Pirate', last_nom: [{ first_nom: '5.1.Laszlo', last_nom: 'Jamf' },
{ first_nom: '5.3Pig', last_nom: 'Bodine' },
{ first_nom: 'Pirate', last_nom: 'Prentice' },
{ first_nom: '5.2 Pirate', last_nom: 'Prentice' },
{ first_nom: 'สัญญาจ้าง', last_nom: 'Prentice' }]
},
{
first_nom: 'สัญญาจ้าง', last_nom: [{ first_nom: '5.1.Laszlo', last_nom: 'Jamf' },
{ first_nom: '5.3Pig', last_nom: 'Bodine' },
{ first_nom: 'Pirate', last_nom: 'Prentice' },
{ first_nom: '5.2 Pirate', last_nom: 'Prentice' },
{ first_nom: 'สัญญาจ้าง', last_nom: 'Prentice' }]
}
];
let main = {
a: 20,
objs: objs
}
function compare(a, b) {
if (a.first_nom < b.first_nom) {
return -1;
}
if (a.first_nom > b.first_nom) {
return 1;
}
return 0;
}
main.objs.forEach((value) => {
return value.last_nom.sort(compare)
})
console.log(JSON.stringify(main, null, 1));