Script – 00-49 Jan 31
I'm very confused at this occurrence
How is actually sorting
![derp](https://cdn.discordapp.com/emojis/674223306580295681.png)
grid[0]
?12 Replies
is that a normal thing?
I do not understand whats going on
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
the if statement is actually sorting grid
whereas I'm just trying to check if grid is sorted
yes, because you're calling
.sort()
, and the if
statement is comparing what that returns
.sort()
does not do any kind of a "is this sorted?" checkUnknown User•3y ago
Message Not Public
Sign In & Join Server To View
and there really isn't an easy way to check if an array is sorted
at least not any kind of built-in API
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
and this exercise says to do so
![](https://cdn.answeroverflow.com/937510904914927636/unknown.png)
taking a look at this.
yeah, so at that point you have to do something like what iggy showed
the point is that there is no generic "is this sorted" function
the answer to "is this sorted" entirely depends on what is inside the array, and that's specific to your app
so yeah, you most likely would need to do some kind of pairwise comparisons all the way down the array
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
This question has an answer! Thank you for helping 😄
If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/937509918062288916
This thread hasn’t had any activity in 12 hours, so it’s now locked.
Threads are closed automatically after 12 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/937509918062288916