First off, an an associative array is the most popular sort of array used which is also sometimes referred to a hash or map structure. It is simply a set of value pairs stored in association with its own key.
For example, when sorting (Cherry, apples) without a compareFunction will result in (Cherry, apples) instead of (apples, Cherry). arr.sort([compareFunction]) is the code for the compareFunction which will sort the data correctly according to alphabetical order as (apples, Cherry). This also applies in the arrangement of numbers. The sort() function would value and sort numbers according to the first digit. So automatically, arranging 5, 12, 9, 80 will result in (12,5,80,90). However, using the compareFunction allows the numbers to be arranged according to their numerical value instead of just the first number.