Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by disabling your ad blocker.

# Moving to Dart from C++

A couple of days ago, while recovering from some flu, I managed to catch up a bit of me reading. If you know anything about the life of an independent contractor, you’d know that there’s never time for your personal projects or hobbies, so this was a most welcome break.

One of my favorite blogs is this one and I saw a great article on Sorting vectors in C++ by Nic Raboy. As it happens, C++ is one of my first commercial languages and I still make some moderate use of it for various mobile projects.

One thing that struck me, as I read the code, was how close this was to the Dart programming language. I’ve been doing a lot of Flutter development of late, and have been making more use of the Dart programming language. Mobile applications often contain complex logic, and this is where Dart has really proven it’s worth to me, in both being a concise and expressive language, but also being familiar enough that I didn’t have to learn everything from scratch to be productive.

In this short tutorial, we’ll take the quicksort algorithm Nic has built in C++ and convert it to Dart. Along the way, we’ll see how close Dart is to C++ and how much of your existing C++ knowledge easily transfers to the Dart environment.

# Sort A Vector Of Integers With The Quicksort Algorithm In C++

If you’re studying computer science, at some point you’re going to be exposed to the Quicksort algorithm. Even if you’re not a computer science student, chances are this particular algorithm will come up at some point in time as part of an interview. I’ve been asked about it plenty of times in interview processes and never once used it again.

Whether or not you’ll ever use the Quicksort algorithm, it is important to know and that is what we’re going to review in this back to the basics tutorial.

In this tutorial we’re going to sort a vector of integer values using the Quicksort algorithm. We’re going to use a vector because it is a commonly used data structure in C++.

# Sort An Integer Array With the Quicksort Algorithm And Java

Circling back to data structures and algorithms, we’re now going to take a look at the efficient sorting algorithm known as Quicksort.

Quicksort via Wikipedia:

Sometimes called partition-exchange sort, is an efficient sorting algorithm, serving as a systematic method for placing the elements of an array in order.

The idea behind Quicksort is to take a large array of values and divide it into two smaller arrays, doing this recursively, and swapping elements.

This is one of the fundamental algorithms you’ll learn in any computer science course. It is also a very good question that could be asked in a job interview for an engineering type position. I’m going to help you through it using Java.

### Subscribe

Subscribe to the newsletter for monthly tips and tricks on subjects such as mobile, web, and game development.