{"id":19655,"date":"2020-12-21T20:26:18","date_gmt":"2020-12-22T04:26:18","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=19655"},"modified":"2023-12-01T04:06:20","modified_gmt":"2023-12-01T12:06:20","slug":"java-selection-sort","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/java-selection-sort\/","title":{"rendered":"Java Selection Sort: A How-To Guide"},"content":{"rendered":"\n<p><em>The Java selection sort finds the smallest item in a list and moves that value to the start of the list. This happens repeatedly until every element in the first list has been sorted. The selection sort returns the sorted list.<\/em><\/p>\n\n\n\n<p>How do you sort a list in Java? You\u2019ve got a few options. One common option is the selection sort.<\/p>\n\n\n\n<p>In this guide, we\u2019re going to talk about what selection sorts are and how they work. We\u2019ll also walk through how to build a selection sort in Java so that you\u2019ll know how to build your own. Let\u2019s get started!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is a Java Selection Sort?<\/h2>\n\n\n\n<p>A selection sort repeatedly finds the minimum item in a list and moves it to the beginning of the unsorted items in the list. This process repeats for every item in a list until the list is ordered.<\/p>\n\n\n\n<p>The first item in the list is considered to be the smallest item. This item is compared with the next element. If the next element is smaller, the elements swap. This algorithm finds the minimum element until the last element is reached. Then, our program moves the smallest item to the start of the list.<\/p>\n\n\n\n<p>In a selection sort, a list contains two parts: the sorted list and the unsorted list. As elements are sorted, they move from the unsorted subarray to the sorted subarray.<\/p>\n\n\n\n<p>You can order a list in either ascending or descending order.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">When Should You Use a Selection Sort?<\/h2>\n\n\n\n<p>Selection sorts are optimal when you need to sort a small list. This is because there are more efficient ways of sorting large lists. Algorithms, such as a merge sort, an insertion sort, and a quick sort, are more efficient than a selection sort in Java programming.<\/p>\n\n\n\n<p>A selection sort performs best when checking all the elements of the array is mandatory. This would be the case if few or none of the items in a list are sorted. Selection sorts usually outperform a bubble sort, which is easier to understand.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How do Selection Sorts Work?<\/h2>\n\n\n\n<p>There\u2019s no use trying to implement an algorithm in Java without first knowing what it is that we want our algorithm to do. Let\u2019s start by walking through the steps a selection sort takes to sort a list in order.<\/p>\n\n\n\n<p>Consider the following unsorted array:<\/p>\n\n\n\n<table class=\"wp-block-table course-info-table\"><tbody><tr><td>17<\/td><td>14<\/td><td>9<\/td><td>12<\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>Selection sorts set the first item as the smallest in the list. This is a temporary value which changes every time our program makes a comparison. This value is stored in its own variable.<\/p>\n\n\n\n<table class=\"wp-block-table course-info-table\"><tbody><tr><td><strong>minimum = 17<\/strong><\/td><td><br><\/td><td><br><\/td><td><br><\/td><\/tr><tr><td>17<\/td><td>14<\/td><td>9<\/td><td>12<\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>The \u201cminimum\u201d item is compared with the second element. This element is in the unsorted part of the array; every element after the sorted elements is unsorted.<\/p>\n\n\n\n<p>Say the second element is smaller than the \u201cminimum\u201d item. In this case, the value of the \u201cminimum\u201d item is set to the value of the second item. 14 is smaller than 17, so our new minimum value becomes 14.<\/p>\n\n\n\n<table class=\"wp-block-table course-info-table\"><tbody><tr><td><strong>minimum = 14<\/strong><\/td><td><br><\/td><td><br><\/td><td><br><\/td><\/tr><tr><td>17<\/td><td>14<\/td><td>9<\/td><td>12<\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>This process repeats for each item in our list. 9 is less than 14. So, the value of \u201cminimum\u201d becomes 9. 9 is not less than 12, so the value of minimum stays the same.<\/p>\n\n\n\n<p>After one iteration, our list has found that 9 is the smallest number. This item is moved to the start of the list:<\/p>\n\n\n\n<table class=\"wp-block-table course-info-table\"><tbody><tr><td>9<\/td><td>17<\/td><td>14<\/td><td>12<\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>This process starts over again from the first unsorted element. So, our next set of comparisons would begin with 17:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>17 is equal to the minimum.<\/li><li>Our program compares 17 with 14. The value of &#8220;minimum&#8221; becomes 14.<\/li><li>Our program compares 14 is with 12. The value of &#8220;minimum&#8221; becomes 12.<\/li><li>Our program moves 12 to end of the sorted items in the list.<\/li><\/ul>\n\n\n\n<p>Our list looks like this:<\/p>\n\n\n\n<table class=\"wp-block-table course-info-table\"><tbody><tr><td>9<\/td><td>12<\/td><td>17<\/td><td>14<\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>This process repeats until our list is ordered. When our algorithm has finished executing, the following list is returned:<\/p>\n\n\n\n<table class=\"wp-block-table course-info-table\"><tbody><tr><td>9<\/td><td>12<\/td><td>14<\/td><td>17<\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>Our list is sorted in ascending order.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Build a Selection Sort in Java<\/h2>\n\n\n\n<p>It\u2019s one thing to know how a selection sort works; it\u2019s another to build one. Let\u2019s code a selection sort in Java that uses the logic we discussed in the walk through.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Set Up the Program<\/h3>\n\n\n\n<p>Create a file called selection_sort.java. We\u2019ll start by importing the <a href=\"https:\/\/careerkarma.com\/blog\/java-array\/\">Java Arrays library<\/a> into our code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.Arrays;<\/pre><\/div>\n\n\n\n<p>We use this library later in our code. We use it to convert our sorted array to a string so that we can print it to the console.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Create a Sort Function<\/h3>\n\n\n\n<p>Next, we\u2019re going to declare a class and create a method which performs our selection sort. Add the following to your <em>selection_sort.java<\/em> file:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>class SelectionSort {\n\tvoid sortNumbers(int array[]) {\n\t\tint size = array.length;\n\n\t\tfor (int item = 0; item &lt; size - 1; item++) {\n\t\t\tint minimum = item;\n\t\t\tfor (int number = minimum + 1; number &lt; size; number++) {\n\t\t\t\tif (array[number] &lt; array[minimum]) {\n\t\t\t\t\tminimum = number;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tint temporary = array[item];\n\t\t\tarray[item] = array[minimum];\n\t\t\tarray[minimum] = temporary;\n\t\t}\n\t}\n}\n<\/pre><\/div>\n\n\n\n<p>In our class, we have defined a method called <em>sortNumbers<\/em> which performs our sort. We start by calculating the length of our array. We store the length of our array in a <a href=\"https:\/\/careerkarma.com\/blog\/java-variables\/\">Java variable<\/a>.<\/p>\n\n\n\n<p>Then, we create a <a href=\"https:\/\/careerkarma.com\/blog\/java-for-each-loops\/\">Java for loop<\/a>. This loop iterates through every item in our list. Inside this for loop, we find the minimum item, which is the first item in the list.<\/p>\n\n\n\n<p>We then start another for loop to compare the minimum item with every item in the list.<\/p>\n\n\n\n<p>If the number the for loop is reading is smaller than the minimum number, the value of \u201cminimum\u201d becomes that number. In our loop, \u201cnumber\u201d represents the index value of the number to which we are comparing to the minimum value.<\/p>\n\n\n\n<p>Once the minimum number has been compared to every number in the list, our inner for loop stops. The minimum number is then moved after all the sorted numbers in the list.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Call the Sort Function<\/h3>\n\n\n\n<p>Our code doesn\u2019t do anything just yet. We haven\u2019t yet called our class and given it a list to sort.<\/p>\n\n\n\n<p>Below the <em>sortNumbers<\/em> method in the list, add the following code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>public static void main(String args[]) {\n\tint[] toSort = { 17, 14, 9, 12 };\n\tSelectionSort newSort = new SelectionSort();\n\tnewSort.sortNumbers(toSort);\n\t\n\tSystem.out.println(Arrays.toString(toSort));\n}\n<\/pre><\/div>\n\n\n\n<p>Inside our main method we have declared a list of items to sort called <em>toSort<\/em>. We then initialize an instance of our SelectionSort class called newSort. We use this to call our <em>sortNumbers<\/em> method, which sorts the values in the toSort array.<\/p>\n\n\n\n<p>After the sortNumbers method has executed, we print out the sorted array to the console. We do this using the <em>Arrays.toString()<\/em> method, which converts our array to a list of strings.<\/p>\n\n\n\n<p>Let\u2019s run our code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>[9, 12, 14, 17]<\/pre><\/div>\n\n\n\n<p>Our list has been sorted!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Selection Sort Java: Sort Values in Descending Order<\/h2>\n\n\n\n<p>It\u2019s worth noting that you can sort values in descending order. To do so, replace the following line of code in your <em>sortNumbers<\/em> method:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>if (array[number] &lt; array[minimum]) {<\/pre><\/div>\n\n\n\n<p>With this code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>if (array[number] &gt; array[minimum]) {<\/pre><\/div>\n\n\n\n<p>This code checks whether the \u201cminimum\u201d value is greater than the one being accessed by the for loop. This means that the value of \u201cminimum\u201d will reflect the highest value in a list instead of the lowest value.<\/p>\n\n\n\n<p>To prevent confusion, you should rename \u201cminimum\u201d to \u201cmaximum\u201d, if you are sorting a list in descending order.<\/p>\n\n\n\n<p>You\u2019ve done it. You have sorted a list in Java using the selection sorting algorithm.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is the Complexity of a Java Selection Sort?<\/h2>\n\n\n\n<p>There are three time complexities that we need to consider when evaluating an algorithm: the best case, the worst case, and average case.<\/p>\n\n\n\n<p>The selection sort has the best, average, and worst case complexity of O(n^2). This means that the algorithm will take exponentially longer as the numbers of the items in a list grow.<\/p>\n\n\n\n<p>Are you confused by the complexity of algorithms? Check out our <a href=\"https:\/\/careerkarma.com\/blog\/big-o-notation-time\/\">two-part series on Big O Notation<\/a>. This is the notation we use to describe the complexity of algorithms.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Selection sorts are an efficient method of sorting lists of data. They work by selecting the smallest item from an unsorted list and moving that item to the beginning of the unsorted list. This process repeats until the list is sorted.<\/p>\n\n\n\n<p>Do you want to become a Java developer? Check out our <a href=\"https:\/\/careerkarma.com\/blog\/how-to-learn-java\/\">How to Learn Java guide<\/a>. You&#8217;ll find top learning tips and advice on the best online courses and learning resources in this guide.<\/p>\n","protected":false},"excerpt":{"rendered":"The Java selection sort finds the smallest item in a list and moves that value to the start of the list. This happens repeatedly until every element in the first list has been sorted. The selection sort returns the sorted list. How do you sort a list in Java? You\u2019ve got a few options. One&hellip;","protected":false},"author":240,"featured_media":19656,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[17289],"tags":[],"class_list":{"0":"post-19655","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-java"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"Java","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v27.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Java Selection Sort: A How-To Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"A selection sort is a simple sorting algorithm that repeatedly finds the smallest element in a list and moves it to the start of a list. On Career Karma, learn about Java selection sorts.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/java-selection-sort\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Selection Sort: A How-To Guide\" \/>\n<meta property=\"og:description\" content=\"A selection sort is a simple sorting algorithm that repeatedly finds the smallest element in a list and moves it to the start of a list. On Career Karma, learn about Java selection sorts.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/java-selection-sort\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-12-22T04:26:18+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T12:06:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/tirza-van-dijk-I8OhOu-wLO4-unsplash.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"667\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/java-selection-sort\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/java-selection-sort\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Java Selection Sort: A How-To Guide\",\"datePublished\":\"2020-12-22T04:26:18+00:00\",\"dateModified\":\"2023-12-01T12:06:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/java-selection-sort\/\"},\"wordCount\":1321,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/java-selection-sort\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/tirza-van-dijk-I8OhOu-wLO4-unsplash.jpg\",\"articleSection\":[\"Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/java-selection-sort\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/java-selection-sort\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/java-selection-sort\/\",\"name\":\"Java Selection Sort: A How-To Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/java-selection-sort\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/java-selection-sort\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/tirza-van-dijk-I8OhOu-wLO4-unsplash.jpg\",\"datePublished\":\"2020-12-22T04:26:18+00:00\",\"dateModified\":\"2023-12-01T12:06:20+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"A selection sort is a simple sorting algorithm that repeatedly finds the smallest element in a list and moves it to the start of a list. On Career Karma, learn about Java selection sorts.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/java-selection-sort\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/java-selection-sort\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/java-selection-sort\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/tirza-van-dijk-I8OhOu-wLO4-unsplash.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/tirza-van-dijk-I8OhOu-wLO4-unsplash.jpg\",\"width\":1000,\"height\":667},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/java-selection-sort\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/careerkarma.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\/\/careerkarma.com\/blog\/java\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Java Selection Sort: A How-To Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\",\"url\":\"https:\/\/careerkarma.com\/blog\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/careerkarma.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Java Selection Sort: A How-To Guide | Career Karma","description":"A selection sort is a simple sorting algorithm that repeatedly finds the smallest element in a list and moves it to the start of a list. On Career Karma, learn about Java selection sorts.","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:\/\/careerkarma.com\/blog\/java-selection-sort\/","og_locale":"en_US","og_type":"article","og_title":"Java Selection Sort: A How-To Guide","og_description":"A selection sort is a simple sorting algorithm that repeatedly finds the smallest element in a list and moves it to the start of a list. On Career Karma, learn about Java selection sorts.","og_url":"https:\/\/careerkarma.com\/blog\/java-selection-sort\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-12-22T04:26:18+00:00","article_modified_time":"2023-12-01T12:06:20+00:00","og_image":[{"width":1000,"height":667,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/tirza-van-dijk-I8OhOu-wLO4-unsplash.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/java-selection-sort\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/java-selection-sort\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Java Selection Sort: A How-To Guide","datePublished":"2020-12-22T04:26:18+00:00","dateModified":"2023-12-01T12:06:20+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/java-selection-sort\/"},"wordCount":1321,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/java-selection-sort\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/tirza-van-dijk-I8OhOu-wLO4-unsplash.jpg","articleSection":["Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/java-selection-sort\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/java-selection-sort\/","url":"https:\/\/careerkarma.com\/blog\/java-selection-sort\/","name":"Java Selection Sort: A How-To Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/java-selection-sort\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/java-selection-sort\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/tirza-van-dijk-I8OhOu-wLO4-unsplash.jpg","datePublished":"2020-12-22T04:26:18+00:00","dateModified":"2023-12-01T12:06:20+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"A selection sort is a simple sorting algorithm that repeatedly finds the smallest element in a list and moves it to the start of a list. On Career Karma, learn about Java selection sorts.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/java-selection-sort\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/java-selection-sort\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/java-selection-sort\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/tirza-van-dijk-I8OhOu-wLO4-unsplash.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/tirza-van-dijk-I8OhOu-wLO4-unsplash.jpg","width":1000,"height":667},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/java-selection-sort\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/careerkarma.com\/blog\/java\/"},{"@type":"ListItem","position":3,"name":"Java Selection Sort: A How-To Guide"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/19655","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=19655"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/19655\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/19656"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=19655"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=19655"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=19655"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}