{"id":128709,"student_id":1404,"content":"/*****************************************************\n練習一\n*****************************************************/\nvar arr = [3, 6, 2, 8, 1, 5, 0, 7, 9, 4];\narr.sort(function (a, b) {\n\n return a - b;\n});\n\n\n\n/*****************************************************\n練習二\n*****************************************************/\n// 目標:將年紀從小排到大並印出\nvar students = [{\n name: '大衛', age: 24\n},\n {\n name: '莉莉', age: 17\n },\n {\n name: '艾蓮', age: 18\n },\n {\n name: '阿伯', age: 30\n },\n {\n name: '威廉', age: 23\n },\n {\n name: '凱文', age: 15\n },\n {\n name: '朵莉絲', age: 22\n }];\n\n// 印出完整物件\nconsole.log('排序前:' + JSON.stringify(students, null, 4));\n\nstudents.sort(function(a, b){\n return a.age - b.age;\n})\n\nconsole.log('排序後:' + JSON.stringify(students, null, 4));\n\n\nvar quiz1 = [4,5,6,2,5,2,3]\nconsole.log('排序前:' + quiz1);\n\nquiz1.sort(function(a, b){\n return a - b;\n})\n\nconsole.log('排序後:' + quiz1);\n\n\n\nvar quiz2 = [{a: 87, b:35}, {a: 11, b:25}, {a: 44, b:21}] \n//按照a由小排到大\nconsole.log('排序前:' + JSON.stringify(quiz2, null, 4));\n\nquiz2.sort(function(x, y){\n return x.a - y.a;\n})\n\nconsole.log('排序後:' + JSON.stringify(quiz2, null, 4));\n\n\n\n\n\n\n\n\n","created_at":"2020-02-22T15:41:09.069+08:00","updated_at":"2020-05-16T17:34:49.773+08:00","name":"內建排序練習 副本","language":"javascript","screenshot":{"url":"https://cdn8.koding.school/uploads/project/screenshot/128709/fd1ac05835b665cf0d7e3c5532c7c2d7.jpg"},"parent_id":31717,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":62,"hashid":"5j3sdqqn","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":2211902,"file_name":"1.wav","project_id":128709,"asset_id":10,"created_at":"2020-02-22T15:41:09.079+08:00","updated_at":"2020-02-22T15:41:09.079+08:00"},{"id":2211903,"file_name":"0.wav","project_id":128709,"asset_id":9,"created_at":"2020-02-22T15:41:09.081+08:00","updated_at":"2020-02-22T15:41:09.081+08:00"},{"id":2211904,"file_name":"2.png","project_id":128709,"asset_id":8,"created_at":"2020-02-22T15:41:09.084+08:00","updated_at":"2020-02-22T15:41:09.084+08:00"},{"id":2211905,"file_name":"1.svg","project_id":128709,"asset_id":7,"created_at":"2020-02-22T15:41:09.086+08:00","updated_at":"2020-02-22T15:41:09.086+08:00"},{"id":2211906,"file_name":"0.png","project_id":128709,"asset_id":6,"created_at":"2020-02-22T15:41:09.088+08:00","updated_at":"2020-02-22T15:41:09.088+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦