How to sort an object dynamically

Yes i agree but there is warning more important than other… my aim is that this a personnal project and i will be the only one to use it, everything is working and you see this only in the Dev tool. Usually i try too but i am not sure that i can solve this with my knowledge without spending a lot of hours…

The literal English meaning of sort (for programmers at least) means to take input such as:

3
8
4
9
2

And process that into the following (using ascending order and default sequencing):

2
3
4
8
9

That could be called merging, correct? For databases it is called a join, correct?

Depends a bit on what language you’re in - for a database, it would be a join, in programming languages, it’s usually either a merge or a zip (as in zipping two sides of a zipper together, merging the two arrays into one by joining elements).

In either case, it was a bit of an oversimplification to say it that way here, as what we desired was both a merge/zip and a mapping of the result into a different form.

1 Like

A zipper is something that joins things. It is not the joined items, it is the connection that holds them together. For computers zip has become a term for compression and that seems like a misuse of the term but people seem to like misusing words. I know of no benefit to use of the term zip instead of merge or join.

I was not describing the entire requirements. I was saying that when an element of an array is combined with other elements then that could be called a merge or join.

Again, it depends on your language.

Ruby calls it zip: https://www.geeksforgeeks.org/ruby-array-zip-function/
So does Python: https://www.w3schools.com/python/ref_func_zip.asp

PHP’s array_merge is what a database would call a UNION, in that it appends the elements of one array onto another, and if keys are specified, clobbers values. PHP doesnt call the action described here a zip either, it simply doesnt have a specific action for this behavior with two; instead, like Javascript, you would have to map the two arrays together.

Relevant to the original question I hope we have provided useful terminology for the future. Perhaps we will continue discussion of terminology elsewhere but I will leave it for further discussion elsewhere.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.