I have a task:

You need to write a function that sorts the tape. Each number in the tape will contain some number. This figure will mean the position that the word will take in the end.

Specification: Numbers can be from 1 to 9. 1 will be the first word (not 0). If the ribbon is empty, return the empty ribbon. The words in the input tape will contain only valid values.

Example:

sortString("g5et ski3lls on6 use1 your2 to4 7top") 

Result:

use1 your2 ski3lls to4 g5et on6 7top.

My question is how to sort the words in a string?

Closed due to the fact that off-topic participants are teran , aleksandr barakin , Dmitry Polyanin , user207618, Air Mar 15 '18 at 6:24 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • " Learning tasks are allowed as questions only on the condition that you tried to solve them yourself before asking a question . Please edit the question and indicate what caused you difficulties in solving the problem. For example, give the code you wrote, trying to solve a problem "- teran, aleksandr barakin, Dmitry Polyanin, Community Spirit, Air
If the question can be reformulated according to the rules set out in the certificate , edit it .

    1 answer 1

    1. split by whitespace
    2. Sort array
      To do this, you need to select a number from the word: +match(/\d+/)
    3. join to get the string again