Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Sort questions from asked by most companies to least companies #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
seanprashad merged 1 commit into seanprashad:master from hiromik:master
Jun 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 31 additions & 7 deletions src/components/Table/index.js
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ const Table = () => {
{
Header: 'Questions',
accessor: 'questions',
disableSortBy: true,
Cell: cellInfo => {
return (
<NavLink
Expand Down Expand Up @@ -189,6 +190,7 @@ const Table = () => {
{
Header: 'Solutions',
accessor: 'solutions',
disableSortBy: true,
Cell: cellInfo => {
const url = cellInfo.row.original.premium
? `${cellInfo.row.original.url}/`
Expand Down Expand Up @@ -234,6 +236,7 @@ const Table = () => {
);
},
accessor: 'pattern',
disableSortBy: true,
Cell: cellInfo => {
const patterns = `${cellInfo.row.original.pattern}`
.split(',')
Expand Down Expand Up @@ -261,6 +264,7 @@ const Table = () => {
{
Header: 'Difficulty',
accessor: 'difficulty',
disableSortBy: true,
Cell: cellInfo => (
<Row>
<Badge
Expand All @@ -276,15 +280,27 @@ const Table = () => {
{
Header: () => {
return (
<div style={{ whiteSpace: 'nowrap' }}>
Companies{' '}
<span data-tip="Companies retrieved from Leetcode Premium (May 2021)">
<FaQuestionCircle />
</span>
</div>
<>
<div
style={{ whiteSpace: 'nowrap', display: 'inline-block' }}
>
Companies{' '}
<span data-tip="Companies retrieved from Leetcode Premium (May 2021)">
<FaQuestionCircle />
</span>
</div>
</>
);
},
accessor: 'companies',
sortType: (a, b) => {
if (a.original.companies.length === b.original.companies.length) {
return 0;
}
return a.original.companies.length > b.original.companies.length
? 1
: -1;
},
Cell: cellInfo => {
const companies = cellInfo.row.original.companies.map(company => {
return (
Expand Down Expand Up @@ -333,7 +349,15 @@ const Table = () => {
<tr {...headerGroup.getHeaderGroupProps()}>
{headerGroup.headers.map(column => (
<th {...column.getHeaderProps()}>
{column.render('Header')}
<div {...column.getSortByToggleProps({ title: null })}>
{column.render('Header')}
{/* eslint-disable-next-line no-nested-ternary */}
{column.isSorted
? column.isSortedDesc
? ' 🔽'
: ' 🔼'
: ''}
</div>
<div>{column.canFilter ? column.render('Filter') : null}</div>
</th>
))}
Expand Down

AltStyle によって変換されたページ (->オリジナル) /