# Reorder Feature

**URL:** <https://community.glideapps.com/t/reorder-feature/69409>\
**Category:** Community Resources\
**Created:** [January 9, 2024, 1:07pm UTC](https://community.glideapps.com/t/reorder-feature/69409 "2024-01-09T13:07:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dilon\_Perera](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/dilon_perera/32/85652_2.png) [@Dilon\_Perera](https://community.glideapps.com/u/Dilon_Perera)\
**Post date:** [January 9, 2024, 1:07pm UTC](https://community.glideapps.com/t/reorder-feature/69409/1 "2024-01-09T13:07:52Z")

</div>

Hello Everyone,

I hope you guys are doing well! Also it’s late, but Merry Christmas and a Happy New Year!

So today I found a great method for reordering. It was inspired by one of the client called Trung. It’s for exercises but can apply for other apps too!

Here’s a video that I made for Trung and you guys can check it too! : [reorder in glide on Vimeo](https://vimeo.com/901132240?share=copy)

> **Here's the JS Codes**
>
> **1) csv\_reorder**
> 
> * * *
> 
> ```auto
> function replaceNumbers(csv, selectedNumber) {
> var numbers = csv.split(',').map(Number);
> 
> var selectedIndex = numbers.indexOf(selectedNumber);
> 
> if (selectedIndex !== -1 && selectedIndex > 0) {
> [numbers[selectedIndex], numbers[selectedIndex - 1]] = [numbers[selectedIndex - 1], numbers[selectedIndex]];
> 
> csv = numbers.join(',');
> }
> 
> return csv;
> }
> 
> var originalCSV = p1;
> var selectedNumber = p2;
> var updatedCSV = replaceNumbers(originalCSV, selectedNumber);
> return(updatedCSV); // Log the updated CSV string
> 
> ```
> 
> **2) csv\_reorder copy**
> 
> * * *
> 
> ```auto
> function replaceNumbersOpposite(csv, selectedNumber) {
> var numbers = csv.split(',').map(Number);
> 
> var selectedIndex = numbers.indexOf(selectedNumber);
> 
> if (selectedIndex !== -1 && selectedIndex < numbers.length - 1) {
> [numbers[selectedIndex], numbers[selectedIndex + 1]] = [numbers[selectedIndex + 1], numbers[selectedIndex]];
> 
> csv = numbers.join(',');
> }
> 
> return csv;
> }
> 
> var originalCSV = p1;
> var selectedNumber = p2;
> var updatedCSV = replaceNumbersOpposite(originalCSV, selectedNumber);
> return(updatedCSV);
> 
> ```

I hope this helps and let me know if there’s something wrong or if there are improvements!

Thank you and Have a great day!
