…does not do what you think it does. Reference types are compared by reference (memory address). What this is asking is, “Is the reference for arr the same as the reference for this anonymous empty array literal that I created just for the purpose of this test?” That will never be true.
for (; arr.length != 0;) {
This is bad JS. That is just a while loop in disguise.
Is that the array you want to be checking it against?
for (let numInd in orderedArr) {
for…in is usually used for iterating it over objects, so it is looking for properties, not indexes. It will work, but indexes are numbers and properties names are strings, so …
If you searched the array methods on MDN, you would find methods that could do each of these loops for you. You definitely should for the first one. For the second one, if you must, I would just use a standard for loop, with indexes.
Yes, we call that “sorting”. There is an array method that will do that for you. What you have works, but it is not the ideal way to do it. Yes, you can use a knife as a screwdriver, but it is not the right tool for the job and is a bad habit. Those prototype methods are very valuable and powerful. But beware, there is a “gotcha” for using the sort method with numbers - read the documentations. Google “MDN array sort”.