{"id":9311,"date":"2019-11-05T16:37:23","date_gmt":"2019-11-05T19:37:23","guid":{"rendered":"http:\/\/kb.elipse.com.br\/en\/?p=9311"},"modified":"2022-08-29T15:13:28","modified_gmt":"2022-08-29T18:13:28","slug":"sorting-out-alphabetically-via-vbscript-with-dictionary","status":"publish","type":"post","link":"https:\/\/kb.elipse.com.br\/en\/sorting-out-alphabetically-via-vbscript-with-dictionary\/","title":{"rendered":"Sorting out alphabetically via VBScript with dictionary."},"content":{"rendered":"<p>Many times, you will need to sort out search results to display them in alphabetic order. To do so, you will need a script. This will sort\u00a0 the results out alphabetically via <strong>VBScript<\/strong>.<\/p>\n<p><b>VBScript<\/b> (Visual Basic Script) is an\u00a0<a title=\"Active Scripting\" href=\"https:\/\/en.wikipedia.org\/wiki\/Active_Scripting\">Active Scripting<\/a>\u00a0language developed by Microsoft that is modeled on Visual Basic. It allows\u00a0<a title=\"Microsoft Windows\" href=\"https:\/\/en.wikipedia.org\/wiki\/Microsoft_Windows\">Microsoft Windows<\/a>\u00a0<a title=\"System administrator\" href=\"https:\/\/en.wikipedia.org\/wiki\/System_administrator\">system administrators<\/a>\u00a0to generate powerful tools for managing computers with\u00a0<a class=\"mw-redirect\" title=\"Error handling\" href=\"https:\/\/en.wikipedia.org\/wiki\/Error_handling\">error handling<\/a>,\u00a0<a title=\"Subroutine\" href=\"https:\/\/en.wikipedia.org\/wiki\/Subroutine\">subroutines<\/a>, and other advanced programming constructs. It can give the user complete control over many aspects of their computing environment. One of its features are Dictionaries.<\/p>\n<p>You will frequently use a dictionary when you need to store items and recover them by name. For example, a dictionary can hold all the environment variables defined by the system or all the values associated with a registry key. However, a dictionary can only store one item for each key value. That is, dictionary keys must all be unique. You should keep this in mind when creating a new one.<\/p>\n<p>To use a Dictionary that returns search results alphabetically, that is, in ABCDE format, you will need to create a function called\u00a0 <strong>SortDictionary<\/strong>.<\/p>\n<p>This article contains a demo application that illustrates how to sort out items alphabetically via <a href=\"https:\/\/www.w3schools.com\/asp\/asp_ref_vbscript_functions.asp\" target=\"_blank\" rel=\"noopener noreferrer\">VBScript<\/a> with the &#8216;<em>dictionary<\/em>&#8216; object and the <strong>SortDictionary <\/strong>function. You will find the demo application for download at the end of this article; we also illustrate this article with an example of script that can be used for its execution.<\/p>\n<p>Below is the code for the demo application at the end of the article:<\/p>\n<pre>'######################### Order Dictionary ##########################\r\nFunction SortDictionary(objDict,intSort)\r\nDim strDict()\r\nDim objKey\r\nDim strKey,strItem\r\nDim X,Y,Z\r\n\r\nZ = objDict.Count\r\n\r\nConst dictKey = 1\r\nConst dictItem = 2\r\n\r\nIf Z > 1 Then\r\nReDim strDict(Z,2)\r\nX = 0\r\nFor Each objKey In objDict\r\nstrDict(X,dictKey) = CStr(objKey)\r\nstrDict(X,dictItem) = CStr(objDict(objKey))\r\nX = X + 1\r\nNext\r\n\r\nFor X = 0 to (Z - 2)\r\nFor Y = X to (Z - 1)\r\nIf StrComp(strDict(X,intSort),strDict(Y,intSort),vbTextCompare) > 0 Then\r\nstrKey = strDict(X,dictKey)\r\nstrItem = strDict(X,dictItem)\r\nstrDict(X,dictKey) = strDict(Y,dictKey)\r\nstrDict(X,dictItem) = strDict(Y,dictItem)\r\nstrDict(Y,dictKey) = strKey\r\nstrDict(Y,dictItem) = strItem\r\nEnd If\r\nNext\r\nNext\r\n\r\nobjDict.RemoveAll\r\n\r\nFor X = 0 to (Z - 1)\r\nobjDict.Add strDict(X,dictKey), strDict(X,dictItem)\r\nNext\r\nSet SortDictionary = objDict\r\nEnd If\r\nEnd Function<\/pre>\n<h3>Related articles<\/h3>\n<hr \/>\n<ul>\n<li><a href=\"https:\/\/kb.elipse.com.br\/en\/using-dictionary-object-in-elipse-e3\/\" target=\"_blank\" rel=\"noopener noreferrer\">Using Dictionary object with Elipse E3.<\/a><\/li>\n<\/ul>\n<h3><\/h3>\n<h3>Attachments:<\/h3>\n<p><a href=\"http:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/10\/9073\/SortingAlgorithm.zip\">SortingAlgorithm.zip<\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Many times, you will need to sort out search results to display them in alphabetic order. To do so, you will need a script. This will sort\u00a0 the results out&hellip;<\/p>\n","protected":false},"author":17,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0},"categories":[763,730,729],"tags":[947,948,921,922,923,890],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to sort out items alphabetically via VBScript with Dictionary.<\/title>\n<meta name=\"description\" content=\"This article features a demo application that illustrates how to sort out items alphabetically via VBScript with Dictionary.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/kb.elipse.com.br\/en\/sorting-out-alphabetically-via-vbscript-with-dictionary\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to sort out items alphabetically via VBScript with Dictionary.\" \/>\n<meta property=\"og:description\" content=\"This article features a demo application that illustrates how to sort out items alphabetically via VBScript with Dictionary.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kb.elipse.com.br\/en\/sorting-out-alphabetically-via-vbscript-with-dictionary\/\" \/>\n<meta property=\"og:site_name\" content=\"Elipse Knowledgebase\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/www.facebook.com\/elipsesoftware\" \/>\n<meta property=\"article:published_time\" content=\"2019-11-05T19:37:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-08-29T18:13:28+00:00\" \/>\n<meta name=\"author\" content=\"Marco Antonio Gomes Silva\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Marco Antonio Gomes Silva\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/kb.elipse.com.br\/en\/sorting-out-alphabetically-via-vbscript-with-dictionary\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/kb.elipse.com.br\/en\/sorting-out-alphabetically-via-vbscript-with-dictionary\/\"},\"author\":{\"name\":\"Marco Antonio Gomes Silva\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/person\/fa6d0b4f046e3b2c208aaf84a40154e9\"},\"headline\":\"Sorting out alphabetically via VBScript with dictionary.\",\"datePublished\":\"2019-11-05T19:37:23+00:00\",\"dateModified\":\"2022-08-29T18:13:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/kb.elipse.com.br\/en\/sorting-out-alphabetically-via-vbscript-with-dictionary\/\"},\"wordCount\":287,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#organization\"},\"keywords\":[\"alphabetic\",\"dictionary\",\"sort\",\"sorted\",\"sorting\",\"VBScript\"],\"articleSection\":[\"Scripts\",\"Elipse E3\",\"English\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/kb.elipse.com.br\/en\/sorting-out-alphabetically-via-vbscript-with-dictionary\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/kb.elipse.com.br\/en\/sorting-out-alphabetically-via-vbscript-with-dictionary\/\",\"url\":\"https:\/\/kb.elipse.com.br\/en\/sorting-out-alphabetically-via-vbscript-with-dictionary\/\",\"name\":\"How to sort out items alphabetically via VBScript with Dictionary.\",\"isPartOf\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#website\"},\"datePublished\":\"2019-11-05T19:37:23+00:00\",\"dateModified\":\"2022-08-29T18:13:28+00:00\",\"description\":\"This article features a demo application that illustrates how to sort out items alphabetically via VBScript with Dictionary.\",\"breadcrumb\":{\"@id\":\"https:\/\/kb.elipse.com.br\/en\/sorting-out-alphabetically-via-vbscript-with-dictionary\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/kb.elipse.com.br\/en\/sorting-out-alphabetically-via-vbscript-with-dictionary\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/kb.elipse.com.br\/en\/sorting-out-alphabetically-via-vbscript-with-dictionary\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"In\u00edcio\",\"item\":\"https:\/\/kb.elipse.com.br\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Sorting out alphabetically via VBScript with dictionary.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/kb.elipse.com.br\/#website\",\"url\":\"https:\/\/kb.elipse.com.br\/\",\"name\":\"Elipse Knowledgebase\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/kb.elipse.com.br\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/kb.elipse.com.br\/#organization\",\"name\":\"Elipse Software\",\"url\":\"https:\/\/kb.elipse.com.br\/\",\"sameAs\":[\"http:\/\/www.facebook.com\/elipsesoftware\"],\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/05\/schererelipse-com-br\/logoElipse.png\",\"contentUrl\":\"https:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/05\/schererelipse-com-br\/logoElipse.png\",\"width\":161,\"height\":58,\"caption\":\"Elipse Software\"},\"image\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/person\/fa6d0b4f046e3b2c208aaf84a40154e9\",\"name\":\"Marco Antonio Gomes Silva\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/7d19cf85bb457f81816ff5d785e3b9f4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/7d19cf85bb457f81816ff5d785e3b9f4?s=96&d=mm&r=g\",\"caption\":\"Marco Antonio Gomes Silva\"},\"url\":\"https:\/\/kb.elipse.com.br\/en\/author\/marco\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to sort out items alphabetically via VBScript with Dictionary.","description":"This article features a demo application that illustrates how to sort out items alphabetically via VBScript with Dictionary.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/kb.elipse.com.br\/en\/sorting-out-alphabetically-via-vbscript-with-dictionary\/","og_locale":"en_US","og_type":"article","og_title":"How to sort out items alphabetically via VBScript with Dictionary.","og_description":"This article features a demo application that illustrates how to sort out items alphabetically via VBScript with Dictionary.","og_url":"https:\/\/kb.elipse.com.br\/en\/sorting-out-alphabetically-via-vbscript-with-dictionary\/","og_site_name":"Elipse Knowledgebase","article_publisher":"http:\/\/www.facebook.com\/elipsesoftware","article_published_time":"2019-11-05T19:37:23+00:00","article_modified_time":"2022-08-29T18:13:28+00:00","author":"Marco Antonio Gomes Silva","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Marco Antonio Gomes Silva","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/kb.elipse.com.br\/en\/sorting-out-alphabetically-via-vbscript-with-dictionary\/#article","isPartOf":{"@id":"https:\/\/kb.elipse.com.br\/en\/sorting-out-alphabetically-via-vbscript-with-dictionary\/"},"author":{"name":"Marco Antonio Gomes Silva","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/person\/fa6d0b4f046e3b2c208aaf84a40154e9"},"headline":"Sorting out alphabetically via VBScript with dictionary.","datePublished":"2019-11-05T19:37:23+00:00","dateModified":"2022-08-29T18:13:28+00:00","mainEntityOfPage":{"@id":"https:\/\/kb.elipse.com.br\/en\/sorting-out-alphabetically-via-vbscript-with-dictionary\/"},"wordCount":287,"commentCount":0,"publisher":{"@id":"https:\/\/kb.elipse.com.br\/#organization"},"keywords":["alphabetic","dictionary","sort","sorted","sorting","VBScript"],"articleSection":["Scripts","Elipse E3","English"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/kb.elipse.com.br\/en\/sorting-out-alphabetically-via-vbscript-with-dictionary\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/kb.elipse.com.br\/en\/sorting-out-alphabetically-via-vbscript-with-dictionary\/","url":"https:\/\/kb.elipse.com.br\/en\/sorting-out-alphabetically-via-vbscript-with-dictionary\/","name":"How to sort out items alphabetically via VBScript with Dictionary.","isPartOf":{"@id":"https:\/\/kb.elipse.com.br\/#website"},"datePublished":"2019-11-05T19:37:23+00:00","dateModified":"2022-08-29T18:13:28+00:00","description":"This article features a demo application that illustrates how to sort out items alphabetically via VBScript with Dictionary.","breadcrumb":{"@id":"https:\/\/kb.elipse.com.br\/en\/sorting-out-alphabetically-via-vbscript-with-dictionary\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kb.elipse.com.br\/en\/sorting-out-alphabetically-via-vbscript-with-dictionary\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/kb.elipse.com.br\/en\/sorting-out-alphabetically-via-vbscript-with-dictionary\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"In\u00edcio","item":"https:\/\/kb.elipse.com.br\/en\/"},{"@type":"ListItem","position":2,"name":"Sorting out alphabetically via VBScript with dictionary."}]},{"@type":"WebSite","@id":"https:\/\/kb.elipse.com.br\/#website","url":"https:\/\/kb.elipse.com.br\/","name":"Elipse Knowledgebase","description":"","publisher":{"@id":"https:\/\/kb.elipse.com.br\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/kb.elipse.com.br\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/kb.elipse.com.br\/#organization","name":"Elipse Software","url":"https:\/\/kb.elipse.com.br\/","sameAs":["http:\/\/www.facebook.com\/elipsesoftware"],"logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/logo\/image\/","url":"https:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/05\/schererelipse-com-br\/logoElipse.png","contentUrl":"https:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/05\/schererelipse-com-br\/logoElipse.png","width":161,"height":58,"caption":"Elipse Software"},"image":{"@id":"https:\/\/kb.elipse.com.br\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/person\/fa6d0b4f046e3b2c208aaf84a40154e9","name":"Marco Antonio Gomes Silva","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/7d19cf85bb457f81816ff5d785e3b9f4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/7d19cf85bb457f81816ff5d785e3b9f4?s=96&d=mm&r=g","caption":"Marco Antonio Gomes Silva"},"url":"https:\/\/kb.elipse.com.br\/en\/author\/marco\/"}]}},"_links":{"self":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts\/9311"}],"collection":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/comments?post=9311"}],"version-history":[{"count":5,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts\/9311\/revisions"}],"predecessor-version":[{"id":13627,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts\/9311\/revisions\/13627"}],"wp:attachment":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/media?parent=9311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/categories?post=9311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/tags?post=9311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}