React Table Sorting

Поділитися
Вставка
  • Опубліковано 6 січ 2025

КОМЕНТАРІ • 124

  • @RagnarD3
    @RagnarD3 2 роки тому +2

    I struggled with building this out for two days straight, copying from multiple other examples. None of them worked and were extremely complex. This worked, I understand it, was even able to expand on its function with ease in around 30 minutes. Absolutely wonderful. Thank you so much. So much.

  • @paschalynukwuani6930
    @paschalynukwuani6930 2 роки тому +2

    Your explanation is simply the best. You are an excellent teacher.

    • @CodewithVoran
      @CodewithVoran  2 роки тому

      Welcome brother

    • @alimammadov3744
      @alimammadov3744 2 роки тому

      @@CodewithVoran Error: Too many re-renders. React limits the number of renders to prevent an infinite loop. i get data as a props and get this error

  • @АннаСеменова-е1р
    @АннаСеменова-е1р 3 роки тому +4

    THANK YOU!!!! Before this tutorial I had to do SOOO many twisted ways to do sorting! Im glad it appeared to be this easy, thanks to you 👍👍👍

  • @aparnas1613
    @aparnas1613 Рік тому +1

    Excellent simple code to do multi column sorting in one go :) I was struggling with lengthy algorithms to find a fix .. It really helped me a lot. Thank u very much for your knowledge share and effort :)

  • @Dev-Phantom
    @Dev-Phantom 2 роки тому +2

    very informative i applied this concept today

  • @davidverano444
    @davidverano444 2 роки тому +3

    Thanks Voran. I'm an Engineer (Facilities / Maintenance , 53 yr old), and i wan to automate some tables, or output for work. Hopefully i will be able to use React to do just that. Your video helps.

    • @CodewithVoran
      @CodewithVoran  2 роки тому

      Nice to meet you sir. If you need any help in react, i can help you sir

  • @shubhamsinghvi9338
    @shubhamsinghvi9338 2 роки тому +1

    Really a great and simple explanation ❤❤❤

  • @matheuspombeiro1675
    @matheuspombeiro1675 6 місяців тому

    Thanks Voran, you helped me a lot!

  • @abcd9967
    @abcd9967 2 роки тому +1

    You just saved my life.. thanks for great video 😊

  • @vigneshlokeshbabu1686
    @vigneshlokeshbabu1686 3 роки тому

    excellent excellent excellent video..... another simple way of code, another idea of coding... thank u so much sir...

    • @CodewithVoran
      @CodewithVoran  3 роки тому

      Thank you vignesh 😍😍. Subscribe to my channel for more useful tutorials

  • @RabbagunduMadhavi
    @RabbagunduMadhavi Рік тому

    This is very interesting . Thanks you because, I solved my problem with your video. before I saw many related videos but i am not able to solve my problem.

  • @Sirius39170
    @Sirius39170 7 місяців тому +1

    Thanks for the video!

  • @PadawanNica
    @PadawanNica 2 роки тому +1

    Im new in that and sound crazy but you save me today , thank you!

    • @Voranzov
      @Voranzov 2 роки тому

      Welcome benjamin

  • @onlygamingsamy
    @onlygamingsamy 2 роки тому +2

    Awesome man but if you also do for numbers then it will be more than awesome but still loves it

  • @treatfortreat2105
    @treatfortreat2105 2 роки тому +1

    Hi, Table working fine in local, when code is uploaded to server , table data freeze.

    • @CodewithVoran
      @CodewithVoran  2 роки тому

      hi. which service did you use to host?

  • @mvsrcm6413
    @mvsrcm6413 2 роки тому

    bro ,just saved my life bro , that's it.

  • @MoMoney75314
    @MoMoney75314 7 місяців тому

    Very very helpful, thank you sir.

  • @irenek8150
    @irenek8150 10 місяців тому

    Thank you so much!! It helped me a lot!

    • @CodewithVoran
      @CodewithVoran  10 місяців тому +1

      Glad it helped you ❤️❤️

  • @keerthanachar
    @keerthanachar 2 роки тому +1

    You saved my day :)

  • @analistadesistemas
    @analistadesistemas 2 роки тому

    You have a new subscriber!

  • @anangyoga1381
    @anangyoga1381 2 роки тому

    thank you good sir, it's clear simple and short. awesome!

  • @rupalgupta5524
    @rupalgupta5524 2 роки тому

    Hey! How can we give some arrows icon and change it as per the order ?

  • @vallishbharadwaja9126
    @vallishbharadwaja9126 Рік тому

    Thank you bro 🙏
    It helped a lot

  • @arjun-de6dr
    @arjun-de6dr 2 роки тому

    Good one man, exactly what I was looking for

  • @ankushdas6896
    @ankushdas6896 2 роки тому +1

    You saved me brother

  • @shashidharrai8110
    @shashidharrai8110 2 роки тому

    Thank you so much it is a great video and u used the simplest way to do things thank you so much ...

  • @zahidshaikh3122
    @zahidshaikh3122 3 роки тому

    Bro you just simplified everything in 7-min video.

    • @CodewithVoran
      @CodewithVoran  3 роки тому

      thanks a lot brother. subscribe for more tutorials

  • @fajarhidayat457
    @fajarhidayat457 2 роки тому

    but how if i added the new data, then the new data is automatically sorting ? the problem is when the new data is added, the position is lower not automatically sorting... do u have solution in this case?

  • @n.dclothing8529
    @n.dclothing8529 2 роки тому

    great video but what happens when we wantonly one column to be sorted?

  • @paalaleksander
    @paalaleksander 2 роки тому

    Thanks a lot! Helped me figure out tables in react

  • @marcofabiopavone5027
    @marcofabiopavone5027 2 роки тому +1

    How to write this in typescript? I have to declare a type for col. I mean: const sorting = (col: *what type?*) => {...}

  • @DylanL9
    @DylanL9 2 роки тому +1

    how would you sort integers? do you have code for that?

    • @blobbyblue02
      @blobbyblue02 2 роки тому +1

      I converted my integers to strings, that seemed to work fine.

  • @akkishivakumar6502
    @akkishivakumar6502 2 роки тому

    how to give color on sorting

  • @prajulsahu9838
    @prajulsahu9838 2 роки тому

    Thanks man, you saved me today!!!

  • @prempanchal8166
    @prempanchal8166 2 роки тому +1

    Great video!! I have a question, How would I be able to sort if one of the fields is empty (null)? Like let's say if some of the email fields are empty, how can I make it sort with empty fields?

    • @VeraVeraniego
      @VeraVeraniego 2 роки тому

      sort all fields and then paste the empty fields at the end

  • @sweta3251
    @sweta3251 3 роки тому +3

    Hey I need to sort ip address...can you plz help here

    • @CodewithVoran
      @CodewithVoran  2 роки тому

      in this case, you don't need to convert toLowercase. a[col] > b[col]

  • @mikepl92
    @mikepl92 3 роки тому +2

    Great video! How would the sorting work if you are trying to target nested data in a json object?

    • @CodewithVoran
      @CodewithVoran  3 роки тому +2

      you can use optional chaining. refer this documentation developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining

  • @BalaramGayen
    @BalaramGayen 3 роки тому

    Great content Sir 🥰🥰

  • @bishaladhikari8691
    @bishaladhikari8691 3 роки тому +1

    Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.
    could u please help

    • @CodewithVoran
      @CodewithVoran  3 роки тому

      Did you use class component?

    • @bishaladhikari8691
      @bishaladhikari8691 3 роки тому +1

      @@CodewithVoran
      my case was little different , i had try to explain u but it became little long
      i have to sort from ascending or desending to this data according to price
      export const products=[
      {
      id:"1",
      image:"/images/p1.jpg",
      title:"Brand Levi WHite Tshirt",
      description:"This impressive paella is a perfect party dish and a fun meal to cook together with yourguests. Add 1 cup of frozen peas along with the mussels, if you like. " ,
      availableSizes:["xs","l","xl"],
      Price:"$50"
      },
      {
      id:"2",
      image:"/images/p2.jpg",
      title:"Women's New fashion Jacket",
      description:"This impressive paella is a perfect party dish and a fun meal to cook together with yourguests. Add 1 cup of frozen peas along with the mussels, if you like. ",
      availableSizes:["x","l","xl"],
      Price:"$90"
      },
      ]
      ..................................................................
      i have to do filter and sort the above data , i had completed the filter but not sort
      const [items,setItems]=React.useState(products);

      const filterItem=(item)=>{
      const updatedItem=products.filter((product)=>{
      return product.availableSizes.indexOf(item)>=0;
      });
      setItems(updatedItem)
      }
      const sortItem=(item)=>{
      const sorted=[...items].sort((a,b)=>
      a[item].toLowerCase()>b[item].toLowerCase() ? 1:-1)
      setItems(sorted);
      }
      ---------------------------------------------------------------


      {
      items.map((prod)=>(.........
      .......................
      )
      -----------------------------------------------------------
      in filter.js i have my menu item
      props.setItems("Price")} >Lowest
      Highest

    • @CodewithVoran
      @CodewithVoran  3 роки тому

      Sorry for the late reply. I'll check and let you know.

  • @zishanali2161
    @zishanali2161 2 роки тому +1

    Thank brother 😊 I

  • @rohitmandaliya
    @rohitmandaliya 2 роки тому

    thank you so much this video is very helpful

  • @dude9835
    @dude9835 9 місяців тому

    mera data ek api sai aa rha hai mai data,setdata ki place pai ky likhu

  • @AbhishekSingh-ot2dv
    @AbhishekSingh-ot2dv 2 роки тому

    great video!!

  • @vishalgatla4606
    @vishalgatla4606 2 роки тому +1

    Thanks man

  • @DeadShot-gm1jj
    @DeadShot-gm1jj 2 роки тому

    why do we have to clone the data [...data], why can't we just use data.sort() ???

  • @VivekBabuBanasuri-pl4zj
    @VivekBabuBanasuri-pl4zj Рік тому

    All the columns are strings, can we do the similar for Number data type in column ? Any one ??

  • @thebestchillsounds4780
    @thebestchillsounds4780 2 роки тому

    It doesn't map and rows don't show up. Any help please?

    • @thebestchillsounds4780
      @thebestchillsounds4780 2 роки тому

      I found solution :) Maybe some can use it. You MUST refresh the page or restart React to see results of map method :)

  • @rashmanfathima952
    @rashmanfathima952 Рік тому

    Can I get the source code Sir, Please!

  • @ayoabimbola777
    @ayoabimbola777 3 роки тому

    Nothing but a lifesaver bro... Thanks a bunch! Can I ask why we are mapping the mock data to state before rendering it?

    • @CodewithVoran
      @CodewithVoran  3 роки тому

      Because react components will only re-render when there are chances to state or props

  • @arunaru7561
    @arunaru7561 2 роки тому

    Tqs bro u made that easy😙😙

  • @amankumarsingh7456
    @amankumarsingh7456 2 роки тому

    thanks bhaiyaji

  • @colton3507
    @colton3507 2 роки тому

    Nice!! Thanks

    • @CodewithVoran
      @CodewithVoran  2 роки тому

      Welcome colton. Subscribe to my channel for more useful tutorials

  • @ruhitbaidya1681
    @ruhitbaidya1681 9 місяців тому

    wonderfull

  • @kekoHere0610
    @kekoHere0610 2 роки тому

    Hi..this video helped me a lot.But how do you sort a column with numbers as data

    • @CodewithVoran
      @CodewithVoran  2 роки тому

      Same way

    • @CodewithVoran
      @CodewithVoran  2 роки тому

      Same code

    • @davilima6995
      @davilima6995 2 роки тому

      but toLowerCase doesn't break the code?

    • @trups11trupti
      @trups11trupti 2 роки тому

      Try this for number:
      const sortingNumber = () => {
      if (order === 'DSC') {
      const sorted = [...orders].sort((a, b) => a.subTotal.exclVat - b.subTotal.exclVat);
      setOrders(sorted);
      setOrder('ASC');
      } else {
      const sorted = [...orders].sort((a, b) => b.subTotal.exclVat - a.subTotal.exclVat);
      setOrders(sorted);
      setOrder('DSC');
      }
      };

  • @ryroio
    @ryroio 3 роки тому

    Thank you!

  • @juguetestoys1137
    @juguetestoys1137 3 роки тому

    Excellent video.
    It would be very powerful to be able to join in REACT both functions: react table sorting with the react search filter table.
    I have tried to join both concepts but I can't do it.
    Maybe you know how to do it ....
    Thank you very much for sharing your knowledge!

    • @CodewithVoran
      @CodewithVoran  3 роки тому +1

      Hi Juguetes. I will do a tutorial of table with both functionalities

    • @juguetestoys1137
      @juguetestoys1137 3 роки тому

      You're a great person. Hopefully you will achieve all your dreams !!

    • @CodewithVoran
      @CodewithVoran  3 роки тому

      Thanks mate. Thank you for your words

    • @varshakotwal3407
      @varshakotwal3407 Рік тому

      @@CodewithVoran plz do it yet u have not done

  • @qweqw1359
    @qweqw1359 2 роки тому

    nice

  • @ishivamgupta1
    @ishivamgupta1 2 роки тому +1

    Thankyouu

  • @arupde6320
    @arupde6320 3 роки тому

    upload regularly ..

  • @lee4551
    @lee4551 2 роки тому

    Hello, thank you for the vidéo
    You should remove the music in the background, your voice is enough

  • @abheemk
    @abheemk 3 роки тому +5

    background music is annoying

    • @CodewithVoran
      @CodewithVoran  3 роки тому +4

      sorry brother. I will reduce the sound of background music in upcoming tutorials.

    • @abheemk
      @abheemk 3 роки тому

      @@CodewithVoran Great content , appreciated 👌🏻

    • @CodewithVoran
      @CodewithVoran  3 роки тому

      @@abheemk thanks brother