How to do a javascript array sort based on the count of a character in a string? : I have a couple of strings in an array

for example:

    String 1: "path/to/file"
    String 2: "path"
    String 3: "path/to/"
    String 4: "path2/to/file"
    String 5: "path2/to/file"
    String 5: "path2/to"

etc...

The thing that i would like to achieve is to sort the array based on the the count of the slash. So the less count slashes on top. 

So it would be like:

    String 1: "path"
    String 2: "path/to/"
    String 3: "path2/to"
    String 4: "path/to/file"
    String 5: "path2/to/file"
    String 6: "path2/to/file"

Thank you for the sollution