<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: ItzEve</title>
    <description>The latest articles on DEV Community by ItzEve (@evelyngosselin).</description>
    <link>https://dev.to/evelyngosselin</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F998996%2F5c7fad6d-8286-43c3-a729-59d1e967d888.jpg</url>
      <title>DEV Community: ItzEve</title>
      <link>https://dev.to/evelyngosselin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/evelyngosselin"/>
    <language>en</language>
    <item>
      <title>Small issue.</title>
      <dc:creator>ItzEve</dc:creator>
      <pubDate>Fri, 30 Dec 2022 11:22:32 +0000</pubDate>
      <link>https://dev.to/evelyngosselin/psa-1850</link>
      <guid>https://dev.to/evelyngosselin/psa-1850</guid>
      <description>&lt;p&gt;I am having a small issue...&lt;/p&gt;

&lt;p&gt;I have a class Movie with a static array Movie[] movies. I implement the Comparable and i overload the method compareTo. If the likes of a movie are same with the likes of another movie then i compare them with alphabetical order. I have to create a quicksort implementation to sort an array of movies. But in line return this.compareTo(m); i got a stack overflow Error. How i am supposed to fix this ?&lt;/p&gt;

&lt;p&gt;` public int compareTo(Movie m) {&lt;br&gt;
            if (this.likes == m.likes) {&lt;br&gt;
                //DefaultComparator cmp = new DefaultComparator();&lt;br&gt;
                return this.compareTo(m);&lt;br&gt;
            } else if (this.likes &amp;gt; m.likes) {&lt;br&gt;
                return 1;&lt;br&gt;
            } else {&lt;br&gt;
                return -1;&lt;br&gt;
            }&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    }

    public static Movie[] sort(Movie[] m) {
        if (m == null || m.length == 0) {
            return null;
        } else {
            movies = m;
            quicksort(0, movies.length - 1); // sort the entire array
            return movies;
        }
    }

    public static void quicksort(int left, int right) {
        int i = left;
        int j = right;
        Movie pivot = movies[left + (right - left) / 2];
        while (i &amp;lt;= j) {
            while (movies[i].compareTo(pivot) == -1) {
                i++;
            }
            while (movies[j].compareTo(pivot) == 1) {
                j--;
            }
            if (i &amp;lt;= j) {
                exch(i, j);
                i++;
                j--;
            }

        }
        if (left &amp;lt; j) {
            quicksort(left, j);
        }
        if (i &amp;lt; right) {
            quicksort(i, right);
        }
    }

    public static void exch(int i, int j) {
        Movie temp = movies[i];
        movies[i] = movies[j];
        movies[j] = temp;
    }`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>emptystring</category>
    </item>
  </channel>
</rss>
