howto sort an array with objects by property value length?
<p>In javascript I have the following array with objects:</p>

<pre><code>var defaultSanitizer = [
    {"word": "large", "replaceWith":"L"},
    {"word": "os", "replaceWith":"One Size"},  
    {"word": "xlarge", "replaceWith":"XL"},
    {"word": "o/s", "replaceWith":"One Size"},
    {"word": "medium", "replaceWith":"M"}
    ...
];
</code></pre>

<p>(in reality this array is much larger)</p>

<p>I want to make a function so I can order the array by the length of a property value e.g. the property "word" of the objects.</p>

<p>Something like this:</p>

<pre><code>function sortArrByPropLengthAscending(arr, property) {

    var sortedArr = [];

    //some code

    return sortedArr;

}
</code></pre>

<p>If I were to run the function sortArrByPropLengthAscending(defaultSanitizer, "word") it should return me a sorted array that looks like this:</p>

<pre><code>sortedArr = [        
    {"word": "os", "replaceWith":"One Size"},  
    {"word": "o/s", "replaceWith":"One Size"},
    {"word": "large", "replaceWith":"L"},
    {"word": "xlarge", "replaceWith":"XL"},        
    {"word": "medium", "replaceWith":"M"}
    ...
]  
</code></pre>

<p>How would you do this?</p>
