Skip to content
Advertisement

How to append elements from a multi-dimensional list into 2nd multi-dimensional list

I am trying to append elements from a multi-dimensional list into a 2nd multi-dimensional list. Here is the code I wrote –

JavaScript

The output I am getting is –

JavaScript

The output I am looking for is of sort –

JavaScript

I want to replace elements of innermost list of “my_list” with the elements of the “ref_list”.

Advertisement

Answer

Try:

JavaScript

Prints:

JavaScript

EDIT: To append elements from 2nd list instead replacing:

JavaScript

Prints:

JavaScript

EDIT2: To add elements of 2nd list at the beginning of first list:

JavaScript

Prints:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement