<p><b>@ENT8R</b> commented on this pull request.</p>

<hr>

<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2381#discussion_r331956670">app/controllers/api/notes_controller.rb</a>:</p>
<pre style='color:#555'>> -      @notes = @notes.order("updated_at DESC").limit(result_limit).preload(:comments)
+      @notes = if params[:sort] == "created_at"
+                 if params[:order] == "oldest"
+                   @notes.order("created_at ASC")
+                 else
+                   @notes.order("created_at DESC")
+                 end
+               else
+                 if params[:order] == "oldest"
+                   @notes.order("updated_at ASC")
+                 else
+                   @notes.order("updated_at DESC")
+                 end
+               end
+
+      @notes = @notes.distinct.limit(result_limit).preload(:comments)
</pre>
<p>BTW: I also added <code>.distinct</code> which was missing before but might also be useful because returning the same note multiple times is not really helpful...</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2381?email_source=notifications&email_token=AAK2OLJXL54DK6QHOV25WE3QNMITFA5CNFSM4I5CYR2KYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCHB5G2A#pullrequestreview-298046312">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLMXVQ372YNT3UF6IA3QNMITFANCNFSM4I5CYR2A">mute the thread</a>.<img src="https://github.com/notifications/beacon/AAK2OLJW4MPYYCMJJEVBLJTQNMITFA5CNFSM4I5CYR2KYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCHB5G2A.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/2381?email_source=notifications\u0026email_token=AAK2OLJXL54DK6QHOV25WE3QNMITFA5CNFSM4I5CYR2KYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCHB5G2A#pullrequestreview-298046312",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/2381?email_source=notifications\u0026email_token=AAK2OLJXL54DK6QHOV25WE3QNMITFA5CNFSM4I5CYR2KYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCHB5G2A#pullrequestreview-298046312",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>