+ 3
https://code.sololearn.com/W8QsOeBp3cpf/?ref=app
I changed the interface a little when outputting the result: I now use the table.
+ 3
then you just need to add it to the array like "array.push(new Side(20, 'b'))"
+ 3
@Oma
I found an error and added the conversion of the first array to Number so that the sorting was correct. Test it.
https://code.sololearn.com/WDPWiyRzjg3Q/?ref=app
+ 2
@Husnul
I have not yet been able to make this option reusable: I can not clear the table. I'm hoping to get a better DOM model to do this too.
+ 1
What is it you would really like to do?
you could make a solution for this specific problem, but I don't know if it would suit the real problem you are having
+ 1
you could make an object with name and length and then put that object into your array
are you using javascript?
+ 1
the easiest way to do this is via javascript, because you just need to make a function like 'function Side(length, name){this.length = length; this.name = name;}'
+ 1
You csn use the concept of ASCII value to sort the second array
+ 1
https://code.sololearn.com/cq8zkqPxj9D9/?ref=app
+ 1
#Tu Zong with dictionary
https://code.sololearn.com/cSTKWjL4tzl5/?ref=app
+ 1
#vadim does not work...
+ 1
@Oma
My input is:
first array 5,2,8,1
second array Cc,g,ui,r
Result:
1...r
2...g
5...Cc
8...ui
+ 1
@vadim it was not clear to me that I had to enter data since the fields were not empty.
+ 1
@Oma
I noticed that sorting still does not work correctly, and I changed the program again. It turned out that sort () by default converts values into strings.
+ 1
@MobPsycho
Yes, this is a problem. But this is a problem of inaccurate formulation of the problem. After sorting the first array ([4,3,6,3] -> [3,3,4,6]) it is not clear which of the original triples is the first and which is the second. And sorting is different: stable and unstable.
However, I will try to take into account this.
+ 1
@vadim ...not so bad
+ 1
@Oma
On Python it was better - I know him better, and I master JavaScript on the go. Here the material is still small, they give only the very basics, so we have to look for more detailed information in other sources.
+ 1
#MobPsycho
I made a 2 versions with the possibility of repetition.