簡體   English   中英

如何按字母順序排列過濾器菜單

[英]How can I order the filter menu in alphabetical order

嗨,我在我的項目中使用reactjs searchkit組件。 根據需要,我需要按字母順序列出過濾器菜單的順序

在下圖中,我需要按字母順序對演員列表進行排序,我該怎么做?

在此處輸入圖片說明

有人知道怎么做嗎?

我基於您的RefinementFilterComponent是無狀態功能組件的假設編寫了以下代碼。

這是與列表和映射有關的開發文檔的鏈接。 https://facebook.github.io/react/docs/lists-and-keys.html

const sortActors = props.title.sort((a, b) => {
  const [aFirst, aLast] = a.split(' ');
  const [bFirst, bLast] = b.split(' ');
    return aLast > bLast ? 1 : -1;
})

const renderActors = sortActors
  .map(actor => 
    <li key={actor.toString()}>
      {actor}
    </li>
  )

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM