{"id":37100,"date":"2024-01-30T10:17:04","date_gmt":"2024-01-30T10:17:04","guid":{"rendered":"https:\/\/accuweb.cloud\/resource\/?post_type=faq&#038;p=37100"},"modified":"2026-02-19T09:48:18","modified_gmt":"2026-02-19T09:48:18","slug":"how-to-use-the-sort-function-in-c","status":"publish","type":"faq","link":"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c","title":{"rendered":"How To Use the Sort function in C++?"},"content":{"rendered":"<h2 class=\"ack-h2\">How To Use the Sort function in C++?<\/h2>\n<p>Sorting is a fundamental operation in computer science and programming. It involves arranging a collection of elements in a specific order. The sort function in C++ is a powerful tool that simplifies the process of sorting arrays, vectors, and other containers. <\/p>\n<p><strong>This guide will explore how to use the sort function effectively with various examples.<\/strong><\/p>\n<ol class=\"ack-ol\">\n<li><a class=\"ack-link-color\" href=\"#Sorting-Arrays\">Sorting Arrays<\/a><\/li>\n<li><a class=\"ack-link-color\" href=\"#Sorting-Vectors\">Sorting Vectors<\/a><\/li>\n<li><a class=\"ack-link-color\" href=\"#User-Defined-Objects\">Sorting User-Defined Objects<\/a><\/li>\n<li><a class=\"ack-link-color\" href=\"#Sorting-Order\">Custom Sorting Order<\/a><\/li>\n<\/ol>\n<h2 class=\"ack-h2\">Introduction to the Sort Function in C++<\/h2>\n<p id=\"Sorting-Arrays\">The sort function in C++ is the part of Standard Library and is defined in the <strong>&lt;algorithm&gt;<\/strong> header. It provides an easy way to sort elements in ascending order by default. The function can be used with various types of containers, including arrays, vectors, and lists. Additionally, the sort function can take advantage of the comparison operators <strong>(&lt;, &gt;, &lt;=, &gt;=, ==, !=)<\/strong> to determine the sorting order.<\/p>\n<h3  class=\"ack-h3\">Sorting Arrays<\/h3>\n<p>Arrays are a fixed-size collection of elements. To sort an array using the sort function, follow these steps:<\/p>\n<div class=\"article-space\"><\/div>\n<pre><code class=\"language-javascript\">\r\n#include &lt;algorithm&gt;\r\n#include &lt;iostream&gt;\r\nint main() {\r\n\u00a0 \u00a0 int arr[] = {5, 2, 8, 1, 3};\r\n\u00a0 \u00a0 int size = sizeof(arr) \/ sizeof(arr[0]);\r\n\u00a0 \u00a0 std::sort(arr, arr + size);\r\n\u00a0 \u00a0 std::cout &lt;&lt; \"Sorted array: \";\r\n\u00a0 \u00a0 for (int i = 0; i &lt; size; ++i) {\r\n\u00a0 \u00a0 \u00a0 \u00a0 std::cout &lt;&lt; arr[i] &lt;&lt; \" \";\r\n\u00a0 \u00a0 }\r\n\u00a0 \u00a0 return 0;\r\n}<\/code><\/pre>\n<div class=\"article-space\"><\/div>\n<p><strong id=\"Sorting-Vectors\">Output<\/strong><\/p>\n<p>Sorted array: 1 2 3 5 8<\/p>\n<h3 class=\"ack-h3\">Sorting Vectors<\/h3>\n<p>Vectors are dynamic arrays that can grow or shrink in size. Sorting a vector is similar to sorting an array:<\/p>\n<div class=\"article-space\"><\/div>\n<pre><code class=\"language-javascript\">\r\n\r\n#include &lt;algorithm&gt;\r\n#include &lt;iostream&gt;\r\n#include &lt;vector&gt;\r\nint main() {\r\n\u00a0 \u00a0 std::vector&lt;int&gt; vec = {5, 2, 8, 1, 3};\r\n\u00a0 \u00a0 std::sort(vec.begin(), vec.end());\r\n\u00a0 \u00a0 std::cout &lt;&lt; \"Sorted vector: \";\r\n\u00a0 \u00a0 for (const auto&amp; num : vec) {\r\n\u00a0 \u00a0 \u00a0 \u00a0 std::cout &lt;&lt; num &lt;&lt; \" \";\r\n\u00a0 \u00a0 }\r\n\u00a0 \u00a0 return 0;\r\n}<\/code><\/pre>\n<div class=\"article-space\"><\/div>\n<p><strong id=\"User-Defined-Objects\">Output<\/strong><\/p>\n<p>Sorted vector: 1 2 3 5 8<\/p>\n<div class=\"cta-btn-top-space ack-extra-image-space\">\t\t<div data-elementor-type=\"section\" data-elementor-id=\"38668\" class=\"elementor elementor-38668\" data-elementor-settings=\"{&quot;ha_cmc_init_switcher&quot;:&quot;no&quot;}\" data-elementor-post-type=\"elementor_library\">\n\t\t\t        <section class=\"elementor-section elementor-top-section elementor-element elementor-element-882321f elementor-section-boxed elementor-section-height-default elementor-section-height-default ct-header-fixed-none ct-row-max-none\" data-id=\"882321f\" data-element_type=\"section\" data-settings=\"{&quot;_ha_eqh_enable&quot;:false}\">\n            \n                        <div class=\"elementor-container elementor-column-gap-default \">\n                    <div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-7cc79cc\" data-id=\"7cc79cc\" data-element_type=\"column\">\n        <div class=\"elementor-widget-wrap elementor-element-populated\">\n                    \n        \t\t<div class=\"elementor-element elementor-element-e31b40f elementor-widget elementor-widget-shortcode\" data-id=\"e31b40f\" data-element_type=\"widget\" data-widget_type=\"shortcode.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-shortcode\"><\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t            <\/div>\n        <\/div>\n                    <\/div>\n        <\/section>\n        \t\t<\/div>\n\t\t<\/div>\n<div class=\"cta-btn-bottom-space\"><\/div>\n<h3 class=\"ack-h3\">Sorting User-Defined Objects<\/h3>\n<p>You can also sort collections of user-defined objects. In this example, let&#8217;s sort a collection of Person objects based on their ages:<\/p>\n<div class=\"article-space\"><\/div>\n<pre><code class=\"language-javascript\">\r\n#include &lt;algorithm&gt;\r\n#include &lt;iostream&gt;\r\n#include &lt;vector&gt;\r\n#include &lt;string&gt;\r\nstruct Person {\r\n\u00a0 \u00a0 std::string name;\r\n\u00a0 \u00a0 int age;\r\n};\r\nbool compareByAge(const Person&amp; a, const Person&amp; b) {\r\n\u00a0 \u00a0 return a.age &lt; b.age;\r\n}\r\nint main() {\r\n\u00a0 \u00a0 std::vector&lt;Person&gt; people = {\r\n\u00a0 \u00a0 \u00a0 \u00a0 {\"Alice\", 25},\r\n\u00a0 \u00a0 \u00a0 \u00a0 {\"Bob\", 30},\r\n\u00a0 \u00a0 \u00a0 \u00a0 {\"Eve\", 22}\r\n\u00a0 \u00a0 };\r\n\u00a0 \u00a0 std::sort(people.begin(), people.end(), compareByAge);\r\n\u00a0 \u00a0 std::cout &lt;&lt; \"Sorted by age:\\n\";\r\n\u00a0 \u00a0 for (const auto&amp; person : people) {\r\n\u00a0 \u00a0 \u00a0 \u00a0 std::cout &lt;&lt; person.name &lt;&lt; \" (\" &lt;&lt; person.age &lt;&lt; \")\\n\";\r\n\u00a0 \u00a0 }\r\n\u00a0 \u00a0 return 0;\r\n}<\/code><\/pre>\n<div class=\"article-space\"><\/div>\n<p><strong id=\"Sorting-Order\">Output<\/strong> <\/p>\n<p>Sorted by age:<br \/>\nEve (22)<br \/>\nAlice (25)<br \/>\nBob (30)<\/p>\n<h3 class=\"ack-h3\">Custom Sorting Order<\/h3>\n<p>The sort function&#8217;s default behavior is to sort elements in ascending order. However, you can specify a custom sorting order using a custom comparator function. In this example, we&#8217;ll sort integers in descending order:<\/p>\n<div class=\"article-space\"><\/div>\n<pre><code class=\"language-javascript\">\r\n#include &lt;algorithm&gt;\r\n#include &lt;iostream&gt;\r\n#include &lt;vector&gt;\r\nbool compareDescending(int a, int b) {\r\n\u00a0 \u00a0 return a &gt; b;\r\n}\r\nint main() {\r\n\u00a0 \u00a0 std::vector&lt;int&gt; nums = {5, 2, 8, 1, 3};\r\n\u00a0 \u00a0 std::sort(nums.begin(), nums.end(), compareDescending);\r\n\u00a0 \u00a0 std::cout &lt;&lt; \"Sorted in descending order: \";\r\n\u00a0 \u00a0 for (const auto&amp; num : nums) {\r\n\u00a0 \u00a0 \u00a0 \u00a0 std::cout &lt;&lt; num &lt;&lt; \" \";\r\n\u00a0 \u00a0 }\r\n\u00a0 \u00a0 return 0;\r\n}<\/code><\/pre>\n<div class=\"article-space\"><\/div>\n<p><strong>Output<\/strong> <\/p>\n<p>Sorted in descending order: 8 5 3 2 1<\/p>\n<h2 class=\"ack-h2\">Conclusion<\/h2>\n<p>The sort function in C++ is a versatile tool for sorting various types of containers.<\/p>\n<p>Whether you&#8217;re dealing with arrays, vectors, or user-defined objects, the sort function simplifies arranging elements in a desired order. By using custom comparator functions, you can achieve complex sorting requirements. Incorporate the sort function into your programming toolkit to organize data in your C++ applications efficiently.<\/p>\n<p>This guide covered the basics of using the sort function with examples ranging from simple <a class=\"ack-link-color\" href=\"https:\/\/accuweb.cloud\/resource\/articles\/arrow-operator-in-c\/\" target=\"_blank\" rel=\"noopener\">arrays<\/a> to custom sorting orders. By mastering this function, you&#8217;ll be well-equipped to handle various sorting tasks in your C++ projects.<\/p>\n<div class=\"cta-btn-top-space ack-extra-image-space\">\t\t<div data-elementor-type=\"section\" data-elementor-id=\"38668\" class=\"elementor elementor-38668\" data-elementor-settings=\"{&quot;ha_cmc_init_switcher&quot;:&quot;no&quot;}\" data-elementor-post-type=\"elementor_library\">\n\t\t\t        <section class=\"elementor-section elementor-top-section elementor-element elementor-element-882321f elementor-section-boxed elementor-section-height-default elementor-section-height-default ct-header-fixed-none ct-row-max-none\" data-id=\"882321f\" data-element_type=\"section\" data-settings=\"{&quot;_ha_eqh_enable&quot;:false}\">\n            \n                        <div class=\"elementor-container elementor-column-gap-default \">\n                    <div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-7cc79cc\" data-id=\"7cc79cc\" data-element_type=\"column\">\n        <div class=\"elementor-widget-wrap elementor-element-populated\">\n                    \n        \t\t<div class=\"elementor-element elementor-element-e31b40f elementor-widget elementor-widget-shortcode\" data-id=\"e31b40f\" data-element_type=\"widget\" data-widget_type=\"shortcode.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-shortcode\"><\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t            <\/div>\n        <\/div>\n                    <\/div>\n        <\/section>\n        \t\t<\/div>\n\t\t<\/div>\n<div class=\"cta-btn-bottom-space\"><\/div>\n","protected":false},"author":1,"featured_media":52879,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","class_list":["post-37100","faq","type-faq","status-publish","has-post-thumbnail","hentry","faq_topics-c-programming","faq_topics-kb","faq_topics-product-documentation","faq_topics-tutorial-series","faq_topics-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.10 (Yoast SEO v24.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How To Use the Sort function in C++? - AccuWeb Cloud<\/title>\n<meta name=\"description\" content=\"Learn how to effectively use the sort function in C++ to arrange arrays, vectors, and other containers with ease.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Use the Sort function in C++?\" \/>\n<meta property=\"og:description\" content=\"Learn how to effectively use the sort function in C++ to arrange arrays, vectors, and other containers with ease.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c\" \/>\n<meta property=\"og:site_name\" content=\"AccuWeb Cloud\" \/>\n<meta property=\"article:modified_time\" content=\"2026-02-19T09:48:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c#article\",\"isPartOf\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c\"},\"author\":{\"name\":\"Jilesh Patadiya\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/#\/schema\/person\/a7a4cbe8405202b537509c757b588c58\"},\"headline\":\"How To Use the Sort function in C++?\",\"datePublished\":\"2024-01-30T10:17:04+00:00\",\"dateModified\":\"2026-02-19T09:48:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c\"},\"wordCount\":385,\"publisher\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/#organization\"},\"image\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c#primaryimage\"},\"thumbnailUrl\":\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg\",\"inLanguage\":\"en-US\"},{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c\",\"url\":\"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c\",\"name\":\"How To Use the Sort function in C++? - AccuWeb Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c#primaryimage\"},\"image\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c#primaryimage\"},\"thumbnailUrl\":\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg\",\"datePublished\":\"2024-01-30T10:17:04+00:00\",\"dateModified\":\"2026-02-19T09:48:18+00:00\",\"description\":\"Learn how to effectively use the sort function in C++ to arrange arrays, vectors, and other containers with ease.\",\"breadcrumb\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c#primaryimage\",\"url\":\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg\",\"contentUrl\":\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg\",\"width\":1280,\"height\":720},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/accuweb.cloud\/resource\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Use the Sort function in C++?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/#website\",\"url\":\"https:\/\/accuweb.cloud\/resource\/\",\"name\":\"AccuWeb Cloud\",\"description\":\"Cutting Edge Cloud Computing\",\"publisher\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/accuweb.cloud\/resource\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/#organization\",\"name\":\"AccuWeb.Cloud\",\"url\":\"https:\/\/accuweb.cloud\/resource\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/04\/accuwebcloud_logo_black_tagline.jpg\",\"contentUrl\":\"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/04\/accuwebcloud_logo_black_tagline.jpg\",\"width\":156,\"height\":87,\"caption\":\"AccuWeb.Cloud\"},\"image\":{\"@id\":\"https:\/\/accuweb.cloud\/resource\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/#\/schema\/person\/a7a4cbe8405202b537509c757b588c58\",\"name\":\"Jilesh Patadiya\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/accuweb.cloud\/resource\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2cea2bdb5bbabb771ee67e96acad7396f25cb1a0c360b9bc4a9ac40cea9cd8b2?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/2cea2bdb5bbabb771ee67e96acad7396f25cb1a0c360b9bc4a9ac40cea9cd8b2?s=96&d=mm&r=g\",\"caption\":\"Jilesh Patadiya\"},\"description\":\"Jilesh Patadiya, the visionary Co-Founder and Chief Technology Officer (CTO) behind AccuWeb.Cloud. Founder &amp; CTO at AccuWebHosting.com. He shares his web hosting insights on the AccuWeb.Cloud blog. He mostly writes on the latest web hosting trends, WordPress, storage technologies, and Windows and Linux hosting platforms.\",\"sameAs\":[\"https:\/\/accuweb.cloud\/resource\",\"https:\/\/www.facebook.com\/accuwebhosting\",\"https:\/\/www.instagram.com\/accuwebhosting\/\",\"https:\/\/www.linkedin.com\/company\/accuwebhosting\/\",\"https:\/\/x.com\/accuwebhosting\",\"https:\/\/www.youtube.com\/c\/Accuwebhosting\"],\"url\":\"https:\/\/accuweb.cloud\/resource\/author\/accuwebadmin\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How To Use the Sort function in C++? - AccuWeb Cloud","description":"Learn how to effectively use the sort function in C++ to arrange arrays, vectors, and other containers with ease.","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:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c","og_locale":"en_US","og_type":"article","og_title":"How To Use the Sort function in C++?","og_description":"Learn how to effectively use the sort function in C++ to arrange arrays, vectors, and other containers with ease.","og_url":"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c","og_site_name":"AccuWeb Cloud","article_modified_time":"2026-02-19T09:48:18+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c#article","isPartOf":{"@id":"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c"},"author":{"name":"Jilesh Patadiya","@id":"https:\/\/accuweb.cloud\/resource\/#\/schema\/person\/a7a4cbe8405202b537509c757b588c58"},"headline":"How To Use the Sort function in C++?","datePublished":"2024-01-30T10:17:04+00:00","dateModified":"2026-02-19T09:48:18+00:00","mainEntityOfPage":{"@id":"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c"},"wordCount":385,"publisher":{"@id":"https:\/\/accuweb.cloud\/resource\/#organization"},"image":{"@id":"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c#primaryimage"},"thumbnailUrl":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg","inLanguage":"en-US"},{"@type":["WebPage","FAQPage"],"@id":"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c","url":"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c","name":"How To Use the Sort function in C++? - AccuWeb Cloud","isPartOf":{"@id":"https:\/\/accuweb.cloud\/resource\/#website"},"primaryImageOfPage":{"@id":"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c#primaryimage"},"image":{"@id":"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c#primaryimage"},"thumbnailUrl":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg","datePublished":"2024-01-30T10:17:04+00:00","dateModified":"2026-02-19T09:48:18+00:00","description":"Learn how to effectively use the sort function in C++ to arrange arrays, vectors, and other containers with ease.","breadcrumb":{"@id":"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c#primaryimage","url":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg","contentUrl":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/07\/NEW-OG-IMAGE-URL.jpg","width":1280,"height":720},{"@type":"BreadcrumbList","@id":"https:\/\/accuweb.cloud\/resource\/articles\/how-to-use-the-sort-function-in-c#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/accuweb.cloud\/resource\/"},{"@type":"ListItem","position":2,"name":"How To Use the Sort function in C++?"}]},{"@type":"WebSite","@id":"https:\/\/accuweb.cloud\/resource\/#website","url":"https:\/\/accuweb.cloud\/resource\/","name":"AccuWeb Cloud","description":"Cutting Edge Cloud Computing","publisher":{"@id":"https:\/\/accuweb.cloud\/resource\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/accuweb.cloud\/resource\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/accuweb.cloud\/resource\/#organization","name":"AccuWeb.Cloud","url":"https:\/\/accuweb.cloud\/resource\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/accuweb.cloud\/resource\/#\/schema\/logo\/image\/","url":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/04\/accuwebcloud_logo_black_tagline.jpg","contentUrl":"https:\/\/accuweb.cloud\/resource\/wp-content\/uploads\/2024\/04\/accuwebcloud_logo_black_tagline.jpg","width":156,"height":87,"caption":"AccuWeb.Cloud"},"image":{"@id":"https:\/\/accuweb.cloud\/resource\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/accuweb.cloud\/resource\/#\/schema\/person\/a7a4cbe8405202b537509c757b588c58","name":"Jilesh Patadiya","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/accuweb.cloud\/resource\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/2cea2bdb5bbabb771ee67e96acad7396f25cb1a0c360b9bc4a9ac40cea9cd8b2?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2cea2bdb5bbabb771ee67e96acad7396f25cb1a0c360b9bc4a9ac40cea9cd8b2?s=96&d=mm&r=g","caption":"Jilesh Patadiya"},"description":"Jilesh Patadiya, the visionary Co-Founder and Chief Technology Officer (CTO) behind AccuWeb.Cloud. Founder &amp; CTO at AccuWebHosting.com. He shares his web hosting insights on the AccuWeb.Cloud blog. He mostly writes on the latest web hosting trends, WordPress, storage technologies, and Windows and Linux hosting platforms.","sameAs":["https:\/\/accuweb.cloud\/resource","https:\/\/www.facebook.com\/accuwebhosting","https:\/\/www.instagram.com\/accuwebhosting\/","https:\/\/www.linkedin.com\/company\/accuwebhosting\/","https:\/\/x.com\/accuwebhosting","https:\/\/www.youtube.com\/c\/Accuwebhosting"],"url":"https:\/\/accuweb.cloud\/resource\/author\/accuwebadmin"}]}},"_links":{"self":[{"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/faq\/37100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/faq"}],"about":[{"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/types\/faq"}],"author":[{"embeddable":true,"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/comments?post=37100"}],"version-history":[{"count":15,"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/faq\/37100\/revisions"}],"predecessor-version":[{"id":53405,"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/faq\/37100\/revisions\/53405"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/media\/52879"}],"wp:attachment":[{"href":"https:\/\/accuweb.cloud\/resource\/wp-json\/wp\/v2\/media?parent=37100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}