Start a Project

Array list Rearrangement in swift

Hello guy, Today we will learn about Array list Rearrangement in swift.

Sometimes we need to change the position of the array like I want to change the array index 6 value to index 2 and remain list is the same as per their position. At that time we need to do array rearrangement. let’s start with an example.

Getting Started:-

Step1:- Firstly, Create an Xcode project

File –> New –> Project –> iOS –> Next and add your project name then create.

Step 2:- Secondly, Create a table view in the storyboard.




Step 3:- Now, Create a swift class and add the code and run the code.

And the output is –


Step 4:- Now, I want to change the position of the array list. In my example I want to change the number nine position at index 2, For this, I need to call a function.

Step 5:- Function calling to change the position. you just need to call

Step 6:- Lastly, Run the project and see the result!!!

In this screenshot, you will see that number nine is shifted to position 2, and the remaining array is the same.

Conclusion:-

In this blog, we have discussed Array list Rearrangement in swift.

I hope this blog will help you to understand the rearrangement process of the array.

To learn about more iOS-related topics, Please click here.

Thanks for reading!!!


Exit mobile version