I'm pretty new to all this, so please be gentle. I'm wanting to find a nice easy way for me to sort my menu items alphabetically in javascript.
When we currently add each "menu" or "submenu" item in, we would have to add it in manually to be alphabetical, is there anyway to get this to sort them alphabetically automatically on the end result?
var menu = new Array();
var submenu = new Array();
var submenutotal = new Array();
var href = new Array();
menu[0] = "";
//-------------------------------------------------------------------------------------------------------
menu[1] = "ADMIN, TRAINING & GENERAL OFFICE";
//----
submenu[100] = "EMTV Guide"; href[100] = "EMTV Store Troubleshooting Guide.pdf"
submenu[101] = "BPP - Bakery Production Planning"; href[101] = "https://walmartglobal.service-now.com/wm_sp?id=wm_sc_cat_item&sys_id=9d5d1371db7793005a887bbb8c961917&parm_u_knowledge_id=b697f183db312b8ccdc832ad7c961919";
submenu[102] = "Cashboard"; href[102] = "admin/cashboard.html";
submenu[103] = "Consumables"; href[103] = "checkouts/consumables/files/consumablesnew.htm";
submenu[104] = "Dynamic Waste Dashboard"; href[104] = "admin/Dynamic_Waste_Dashboard.html";
submenu[105] = "Emergency Incident Management App"; href[105] = "admin/EIC/EIC.html";
submenu[106] = "FPP - Fresh Production Planning"; href[106] = "admin/fpp/fpp_main_new.html";
submenu[107] = "GNFR"; href[107] = "admin/gnfr/gnfr.html";
submenu[108] = "Item Not On File (NOF)"; href[108] = "admin/nofform.htm";
submenu[109] = "Merlin"; href[109] = "admin/merlin.html";
submenu[110] = "MTR Stuck In Research Mode"; href[110] = "admin/mtrresearch.htm";
submenu[111] = "Online P&L Access Issue"; href[111] = "admin/pandl_access.html";
submenu[112] = "Product Withdrawal"; href[112] = "admin/pwr.html";
submenu[113] = "Receive it Right / APMI Issue"; href[113] = "https://walmartglobal.service-now.com/wm_sp?id=wm_kb_article&sys_id=1f971d13db306f442c09568bdc961945";
submenu[114] = "RMI Reporting"; href[114] = "admin/rmi.html";
submenu[115] = "Shrink Analytics"; href[115] = "admin/tlmi_exception_reporting/tlmi.html";
submenu[116] = "Store Training Issue"; href[116] = "store_training/home_page.html";
submenu[117] = "Telxon Cabinet"; href[117] = "admin/telxon_cabinet.html";
//-----
submenutotal[1] = 18;
//-----
//-------------------------------------------------------------------------------------------------------
menu[2] = "AVAILABILITY APP";
//----
submenu[200] = "Click here"; href[200] = "Availability_app/Availabilty_application.html";
//----
submenutotal[2] = 1;
//----
//--------------------------------------------------------------------------------------------------------
menu[3] = "AWT (ACTUAL WAIT TIME)";
//----
submenu[300] = "AWT Cameras"; href[300] = "qclarity/camera_ts.html";
//submenu[301] = "MyMetrics"; href[301] = "qclarity/issue_db.html";
//----
submenutotal[3] = 1;
//-----
//-------------------------------------------------------------------------------------------------------
menu[4] = "BWS APPLICATION (BEER, WINE AND SPIRITS)";
//----
submenu[400] = "Click Here"; href[400] = "http://uknts2000.homeoffice.uk.wal-mart.com/ccuksitefiles/isd/helpdeskpatient/bws/main.html";
//----
submenutotal[4] = 1;
//-----
//-------------------------------------------------------------------------------------------------------
menu[5] = "CASH OFFICE";
//----
submenu[500] = "Cash Office Software"; href[500] = "cashoffice/cashofficesoftware.htm";
submenu[501] = "Cashmaster"; href[501] = "cashoffice/cashmaster/onemaxselect.htm";
submenu[502] = "EPOS Reports"; href[502] = "cashoffice/eposreports.htm";
submenu[503] = "Glory Cash Counter"; href[503] = "cashoffice/glory_cash_counter/glory.html";
//----
submenutotal[5] = 4;
//-----
//-------------------------------------------------------------------------------------------------------
menu[6] = "CHECKOUTS";
//----
submenu[600] = "Cash Drawer"; href[600] = "checkouts/cashdrawer/cashdrawer_selection.html";
submenu[601] = "Chip & Pin (PED Device)"; href[601] = "checkouts/chipandpinv3/lane_selection.html";
submenu[602] = "Conveyor Belt"; href[602] = "checkouts/conveyorbelt/conveyorbelt.htm";
submenu[603] = "Checkout Scanners"; href[603] = "checkouts/scannerscalenew/scannerscale_selection.html";
submenu[604] = "Error Codes On Register"; href[604] = "checkouts/errorcodesonregister/errorcodesonregister.htm";
//submenu[604] = "Gift Card Action Codes"; href[604] = "checkouts/giftcardactioncodes/giftcardactioncodes.htm";
submenu[605] = "Handheld Scanner"; href[605] = "checkouts/handheldscanner/index.htm";
//submenu[606] = "How To Dump A Register"; href[606] = "checkouts/howtodumparegister/dumpregister4800.htm";
//submenu[607] = "How To Renumber A Register"; href[607] = "checkouts/howtodumparegister/RenumberLane.htm";
submenu[606] = "Keyboard"; href[606] = "checkouts/keyboard/keyboard.htm";
submenu[607] = "Register Dead?"; href[607] = "checkouts/displays/files/baseunit.htm";
submenu[608] = "Register Displays"; href[608] = "checkouts/displays/files/display.htm";
submenu[609] = "Register Printer"; href[609] = "checkouts/printer/printer.htm";
submenu[610] = "Self Checkout Optional Receipt Printing"; href[610] = "checkouts/selfcheckouts/optional_receipt.html";
submenu[611] = "Self Checkout Permanent Card Only Mode"; href[611] = "checkouts/selfcheckouts/cardonlymode.html";
submenu[612] = "Self Checkout 10 Pound Polymer Note Guide"; href[612] = "User Guide - 10 polymer.pdf";
submenu[613] = "Q Clarity"; href[613] = "QClarity/q_clarity_selection.html";
submenu[614] = "V6 Self Checkouts"; href[614] = "checkouts/ncrv6/landing.html";
submenu[615] = "Vocovo"; href[615] = "http://uknts2000.homeoffice.uk.wal-mart.com/ccuksitefiles/isd/helpdeskpatient/vocovo/homenew.html";
//----
submenutotal[6] = 16;
//-----
//-------------------------------------------------------------------------------------------------------
menu[7] = "COMPUTERS";
//----
//submenu[700] = "CBL Computer"; href[700] = "cbls/cbls_disabled.html";
submenu[700] = "EPOS Computer"; href[700] = "admin/eposcomputer/epos.htm";
submenu[701] = "Thin Client Computer"; href[701] = "thinclient/thin_client_selection.htm";
submenu[702] = "Bakery Keyboard"; href[702] = "counters/files/keyboard.htm";
submenu[703] = "Workbench Computer"; href[703] = "workbench/workbench.htm";
//-----
submenutotal[7] = 4;
//-----
//-------------------------------------------------------------------------------------------------------
menu[8] = "HANDHELD DEVICES";
//----
submenu[800] = "Handheld Devices"; href[800] = "new_handheld_devices/handheld_devices_selection.html";
submenu[801] = "Rascals"; href[801] = "handheld_devices/Rascal_contact.html";
//----
submenutotal[8] = 2;
//-----
//-------------------------------------------------------------------------------------------------------
menu[9] = "HOME SHOPPING";
//----
submenu[900] = "GIF"; href[900] = "homeshopping/gif/gif_issues_new.html";
submenu[901] = "Home Shopping Consumables"; href[901] = "https://walmartglobal.service-now.com/wm_sp?id=kb_article_view&sys_kb_id=0fd70e111bc8ec58daed0fe3cc4bcbd5";
submenu[902] = "Microlise"; href[902] = "homeshopping/microlise/microlise.htm";
submenu[903] = "Mobile Check In"; href[903] = "homeshopping/microlise/mci_no_notification.html";
submenu[904] = "Looker"; href[904] = "homeshopping/microlise/New_Microlise/Looker_selection.html";
//submenu[905] = "Scale & Battery"; href[905] = "homeshopping/hsscale/scale.htm";
submenu[905] = "Store Kit"; href[905] = "https://walmartglobal.service-now.com/wm_sp?id=wm_sc_cat_item&sys_id=b80fb515dbbfefc06da8581bdc9619bb&parm_u_knowledge_id=374d4e64db4873400e7932ab7c9619b5";
//----
submenutotal[9] = 6;
//-----
//-------------------------------------------------------------------------------------------------------
menu[10] = "IMS";
//----
submenu[1000] = "Click Here"; href[1000] = "Natashas_law/nl_ims/IMS_device_selection.html";
//----
submenutotal[10] = 1;
//-----
//-------------------------------------------------------------------------------------------------------
menu[11] = "IP TELEPHONE";
//----
submenu[1100] = "101 Non Urgent Calls To Police"; href[1100] = "IPT/101-Non-Urgent-Calls-to-Police.html";
submenu[1101] = "Ascom (Cordless Phones and RSTU's)"; href[1101] = "IPT/ascomhandset.html";
submenu[1102] = "ASDA ISD Telecoms"; href[1102] = "IPT/ASDA-ISD-Telecoms.html";
// submenu[1103] = "BT Pay Phones"; href[1103] = "IPT/BT_Payphones.html";
submenu[1103] = "Call Quality And Coverage"; href[1103] = "IPT/basestation.html";
submenu[1104] = "Centralised Switchboard"; href[1104] = "IPT/csb.html";
// submenu[1105] = "Checkout Intercom (RSTU)"; href[1105] = "IPT/RSTU/RSTU_selection.html";
submenu[1105] = "Cisco (Desk Phones)"; href[1105] = "IPT/Cisco_Desk_Phone.html";
submenu[1106] = "Fax Guide"; href[1106] = "IPT/Fax_Guide.html";
submenu[1107] = "IP Information Request"; href[1107] = "IPT/ip_information_request.html";
submenu[1108] = "Network Cable / Port Issues"; href[1108] = "https://walmartglobal.service-now.com/wm_sp?id=wm_kb_article&sys_id=a2623b7cdb65a704cfa032ab7c961956";
//----
submenutotal[11] = 9;
//----
//-------------------------------------------------------------------------------------------------------
menu[12] = "NEWSFLASH";
//----
submenu[1200] = "Click Here"; href[1200] = "newsflash/home.html";
//----
submenutotal[12] = 1;
//-----
//-------------------------------------------------------------------------------------------------------
menu[13] = "ONEASDA";
//----
submenu[1300] = "Click Here"; href[1300] = "walmartone/main_menu.htm";
//----
submenutotal[13] = 1;
//-----
//-------------------------------------------------------------------------------------------------------
menu[14] = "OPTICAL";
//----
submenu[1400] = "Equipment Or Facility Issues"; href[1400] = "optical/menu_page.htm";
submenu[1401] = "Optical Reporting"; href[1401] = "https://walmartglobal.service-now.com/wm_sp?id=wm_kb_article&sys_id=0365d01e1b239c544e730fe3cc4bcbc6";
submenu[1402] = "Reporting Optical Errors"; href[1402] = "https://walmartglobal.service-now.com/wm_sp?id=wm_kb_article&sys_id=dd1abfaa1bdeac904e730fe3cc4bcbfe"
submenu[1403] = "Reporting Optical Concerns"; href[1403] = "https://walmartglobal.service-now.com/wm_sp?id=wm_kb_article&sys_id=be7abfae1bdeac904e730fe3cc4bcbe5";
//----
submenutotal[14] = 4;
//-----
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
menu[15] = "PAYPOINT";
//----
submenu[1500] = "Click here"; href[1500] = "paypoint/paypoint.html";
//----
submenutotal[15] = 1;
//----
//-------------------------------------------------------------------------------------------------------
menu[16] = "PEOPLE";
//----
submenu[1600] = "Colleague Online (Brassring)"; href[1600] = "personnel/Colleague_online/colleague_online_v2.html";
submenu[1601] = "Customer First Scheduling"; href[1601] = "personnel/FAST/new_scheduling/scheduling_new.html";
submenu[1602] = "Customer First Scheduling Mobile"; href[1602] = "personnel/customerfirstmobile.html"
submenu[1603] = "Customer First Scheduling Workbook"; href[1603] = "personnel/FAST/new_scheduling/scheduling_workbook.pdf";
submenu[1604] = "Fair Employment NI"; href[1604] = "https://walmartglobal.service-now.com/wm_sp?id=wm_sc_cat_item&sys_id=51f356bedbe86f0832af7f698c961947&parm_u_knowledge_id=a7d4bfbcdba5a704cfa032ab7c9619c9";
// submenu[1605] = "Fast Tasks"; href[1605] = "personnel/FAST/Fast_troubleshooting.html";
// submenu[1605] = "Maintenance SMART"; href[1605] = "personnel/maintenancesmart.htm";
submenu[1605] = "People Desktop"; href[1605] = "personnel/people_desktop/splash.htm";
// submenu[1607] = "Peoplesoft"; href[1607] = "personnel/Peoplesoft/Personnel_default2.html";
submenu[1606] = "Workbrain"; href[1606] = "personnel/workbrain/workbrain.htm";
submenu[1607] = "PeopleSoft Access"; href[1607] = "https://walmartglobal.service-now.com/wm_sp?id=sc_cat_item&sys_id=0eba3a5bdb75afc0b1fb7f698c9619b2";
//----
submenutotal[16] = 8;
//-----
//-------------------------------------------------------------------------------------------------------
menu[17] = "PFS PHONE LINES";
//----
submenu[1700] = "DCD Or Emergency Box"; href[1700] = "https://walmartglobal.service-now.com/wm_sp?id=wm_kb_article&sys_id=68719337dbfce7800e7932ab7c96190e";
submenu[1701] = "Kiosk / Automated Control Room Phone"; href[1701] = "https://walmartglobal.service-now.com/wm_sp?id=wm_kb_article&sys_id=901a963ddbcde780e7a8347b7c9619ce";
submenu[1702] = "Yellow Help Phone"; href[1702] = "https://walmartglobal.service-now.com/wm_sp?id=wm_kb_article&sys_id=24df8ebddb0de780e7a8347b7c96190f";
//----
submenutotal[17] = 3;
//-----
//-------------------------------------------------------------------------------------------------------
menu[18] = "PRINTERS";
//----
submenu[1800] = "Click Here"; href[1800] = "printers/home_shopping.html";
//----
submenutotal[18] = 1;
//-----
//-------------------------------------------------------------------------------------------------------
menu[19] = "PHARMACY";
//----
submenu[1900] = "Equipment Or Facility Issues"; href[1900] = "new_pharmacy/selection.html";
submenu[1901] = "Reporting Pharmacy Concerns"; href[1901] = "https://walmartglobal.service-now.com/wm_sp?id=wm_kb_article&sys_id=e53a3b2e1bdeac904e730fe3cc4bcbab";
//----
submenutotal[19] = 2;
//-----
//-------------------------------------------------------------------------------------------------------
menu[20] = "RECEIVING APPLICATION";
//----
submenu[2000] = "Click Here"; href[2000] = "receiving_app/main.html";
//----
submenutotal[20] = 1;
//-----
//-------------------------------------------------------------------------------------------------------
menu[21] = "RETAIL REPORTING HUB";
//----
submenu[2100] = "Click Here"; href[2100] = "https://walmartglobal.service-now.com/wm_sp?id=sc_cat_item&sys_id=3e604493dbfdd4d49eeb6033ca9619b1&parm_u_knowledge_id=ae8c3371db961818a5546275ca961982";
//----
submenutotal[21] = 1;
//-----
//-------------------------------------------------------------------------------------------------------
menu[22] = "SCALES";
//----
submenu[2200] = "How To Download PLUs"; href[2200] = "counters/files/reloadscales.htm";
submenu[2201] = "Scales"; href[2201] = "counters/countersnew.htm";
submenu[2202] = "Scale Software (PLUs, etc)"; href[2202] = "counters/files/scalemanagement.htm";
submenu[2203] = "Bread Weigh Scales (FX 220) - Call City on #6199"; href[2203] = "#";
//-----
submenutotal[22] = 4;
//-----
//-------------------------------------------------------------------------------------------------------
menu[23] = "SCAN AND GO";
//----
submenu[2300] = "Click Here"; href[2300] = "new_sandg/selection.html";
//-----
submenutotal[23] = 1;
//-----
//-------------------------------------------------------------------------------------------------------
menu[24] = "SEMAFOR";
//----
submenu[2400] = "Click Here"; href[2400] = "Semafor/Semafor_main.html";
//----
submenutotal[24] = 1;
//-------------------------------------------------------------------------------------------------------
menu[25] = "SHOPFLOOR";
//----
//submenu[2500] = "BATCH LABEL PRINTING"; href[2500] = "shop floor/batch_label_printing.html";
submenu[2500] = "Always Available"; href[2500] = "Availability/availability.html";
submenu[2501] = "eSELs (Stevenage Only)"; href[2501] = "https://walmartglobal.service-now.com/wm_sp?id=wm_kb_article&sys_id=a650bf64dbcc2010eaf5b8ff2996197e";
submenu[2502] = "Item Traceability Report"; href[2502] = "https://walmartglobal.service-now.com/wm_sp?id=wm_sc_cat_item&sys_id=8c540307db28274832af7f698c9619c7&parm_u_knowledge_id=01ca6a78dbf12748cdc832ad7c96199d";
//submenu[2503] = "Markdowns"; href[2503] = "https://walmartglobal.service-now.com/wm_sp?id=wm_sc_cat_item&sys_id=8c540307db28274832af7f698c9619c7&parm_u_knowledge_id=674b6ab0db352748cdc832ad7c9619af";
submenu[2503] = "PROMO INDICATOR"; href[2503] = "https://walmartglobal.service-now.com/wm_sp?id=wm_sc_cat_item&sys_id=8c540307db28274832af7f698c9619c7&parm_u_knowledge_id=8ddb667cdb352748cdc832ad7c961924";
submenu[2504] = "SUSI"; href[2504] = "https://walmartglobal.service-now.com/wm_sp?id=wm_sc_cat_item&sys_id=8c540307db28274832af7f698c9619c7&parm_u_knowledge_id=754c6ab0db752748cdc832ad7c961935";
submenu[2505] = "SSPIB"; href[2505] = "https://walmartglobal.service-now.com/wm_sp?id=wm_kb_article&sys_id=faaca678db752748cdc832ad7c961962";
//-----
submenutotal[25] = 6;
//-----
//-------------------------------------------------------------------------------------------------------
menu[26] = "SMART PASSWORD RESET";
//----
submenu[2600] = "SMART Pasword Reset"; href[2600] = "smart_password/Smart_password_reset.html";
submenu[2601] = "2step Setup"; href[2601] = "https://svipreg.wal-mart.com/";
//----
submenutotal[26] = 2;
//-----
//-------------------------------------------------------------------------------------------------------
menu[27] = "SPARK 2.0";
//----
submenu[2700] = "Click Here"; href[2700] = "new_spark/home.html";
//----
submenutotal[27] = 1;
//-----
//-------------------------------------------------------------------------------------------------------
menu[28] = "STORE EMAIL";
//----
submenu[2800] = "Retention Rules"; href[2800] = "email/retention_rules.html";
submenu[2801] = "Mailbox Allowances/Reducing Size"; href[2801] = "https://walmartglobal.service-now.com/wm_sp?id=wm_kb_article&sys_id=405dea321b455d1006c5a865624bcbf6";
//----
submenutotal[28] = 2;
//-----
//-------------------------------------------------------------------------------------------------------
menu[29] = "SURECHECK";
//----
submenu[2900] = "Click Here"; href[2900] = "surecheck/main.html";
//----
submenutotal[29] = 1;
//-----
//-------------------------------------------------------------------------------------------------------
menu[30] = "TOYOU PARCELS COLLECTION & RETURNS";
//----
submenu[3000] = "Collections"; href[3000] = "click and collect/cleveron/Cleveron_Selection.html";
submenu[3001] = "Returns"; href[3001] = "click and collect/parcel_kiosk/parcel_kiosk_home.htm";
submenu[3002] = "toyou Mobile Check-In"; href[3002] = "https://walmartglobal.service-now.com/wm_sp?id=wm_kb_article&sys_id=02d918abdb54e8d47d5fb18f29961969";
//-----
submenutotal[30] = 3;
//-----
//-------------------------------------------------------------------------------------------------------
menu[31] = "TRADE MY STORE";
//----
submenu[3100] = "Click Here"; href[3100] = "trade_my_store/temp_banner_page.html";
//----
submenutotal[31] = 1;
//-----
//-------------------------------------------------------------------------------------------------------
menu[32] = "3rd PARTY DELIVERIES";
//----
submenu[3200] = "Express Delivery (Daas)"; href[3200] = "https://uknts2000.homeoffice.uk.wal-mart.com/ccuksitefiles/isd/helpdeskpatient/ubereats/express_delivery_daas.html";
submenu[3201] = "Integrated Market Place (UberEats/JustEat)"; href[3201] = "https://uknts2000.homeoffice.uk.wal-mart.com/ccuksitefiles/isd/helpdeskpatient/ubereats/integrated_market_place.html";
//----
submenutotal[32] = 2;
//-----
//-------------------------------------------------------------------------------------------------------
menu[33] = "VISION CENTRE";
//----
submenu[3300] = "Handscanner Barcodes"; href[3300] = "vision_center/handscanner_barcodes.html";
//----
submenutotal[33] = 1;
//-----
//-------------------------------------------------------------------------------------------------------
menu[34] = "WAREHOUSE";
//----
submenu[3400] = "MTR Stuck in Research"; href[3400] = "faqs/files/mtrresearch.htm";
submenu[3401] = "Delivery not Finalised"; href[3401] = "faqs/files/initial.htm";
submenu[3402] = "Supply Update Page"; href[3402] = "wire/supplypage.html";
//submenu[3403] = "Trade My Store"; href[3403] = "https://walmartglobal.service-now.com/wm_sp?id=wm_sc_cat_item&sys_id=8c540307db28274832af7f698c9619c7&parm_u_knowledge_id=b65f26f0db392748cdc832ad7c9619ba";
//-----
submenutotal[34] = 3;
//-----
//-------------------------------------------------------------------------------------------------------
menu[35] = "FREQUENTLY ASKED QUESTIONS";
//----
submenu[3500] = "Click here"; href[3500] = "faqs/files/contentspage.htm";
//----
submenutotal[35] = 1;
//----
//-------------------------------------------------------------------------------------------------------
menu[36] = "MOBILE PHONES AND 3G DEVICES";
//----
//submenu[3400] = "Colleague Application - POC"; href[3400] = "http://uknts2000.homeoffice.uk.wal-mart.com/ccuksitefiles/isd/helpdeskpatient/mobile_phones/POClanding.htm";
submenu[3600] = "Click here"; href[3600] = "https://walmartglobal.service-now.com/wm_sp?id=kb_article_view&sys_kb_id=f7c0791cdb3bd0584d0c3a8f29961936";
//----
submenutotal[36] = 1;
//----
//-------------------------------------------------------------------------------------------------------
menu[37] = "MONEY TRANSFERS";
//----
submenu[3700] = "Money Transfers Guide"; href[3700] = "A Step-by-Step Money Transfer Guide-2018 .pdf";
//----
submenutotal[37] = 1;
//----
//-------------------------------------------------------------------------------------------------------
menu[38] = "HFSS";
//----
submenu[3800] = "HFSS Guide"; href[3800] = "HFSS_Guide_2022.pdf";
//----
submenutotal[38] = 1;
//----
//-------------------------------------------------------------------------------------------------------
CodePudding user response:
Javascript has it's own sorting function that you can customise to make alphabetical, this article should help: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort.
As mentioned by the comment though, this question is about Javascript, which is a different language to Java.
Also, people can sometimes be short tempered on here, so try googling the answer to avoid the wrath! A quick search of 'javascript sort' gave me that article above among other ones that could help you.
CodePudding user response:
You can just use the default sort() algorithm from javascript.
The sort() method sorts an array alphabetically:
https://www.w3schools.com/js/js_array_sort.asp
let menu = ["Cashboard", "ADMIN, TRAINING & GENERAL OFFICE", "Merlin", "Consumables", "Z", "Y", "E", "W", "X", "D"];
menu.sort();
console.log(menu);
I saw this, but does this mean I would have to list every menu item for both "menu" and "submenu" to sort them?
At the of your array assignment simply call those for your menu and submenu, than it is automatically sorted alphabeticall.
//menu assignment
let menu = ["Menu 2", "Menu 1", "Menu 5"]
let submenu = ["Submenu 1", "Submenu 5", "Submenu 6", "Submenu 3"]
....
//menu assignment finished, arrays filled
menu.sort();
submenu.sort();
//end of function