diff --git a/.changeset/heavy-rings-play.md b/.changeset/heavy-rings-play.md
new file mode 100644
index 0000000000..fc647f2491
--- /dev/null
+++ b/.changeset/heavy-rings-play.md
@@ -0,0 +1,5 @@
+---
+'@backstage/plugin-bazaar': patch
+---
+
+Adding decending sort in a bazaar plugin
diff --git a/plugins/bazaar/src/components/SortMethodSelector/SortMethodSelector.tsx b/plugins/bazaar/src/components/SortMethodSelector/SortMethodSelector.tsx
index d29211dc44..2ce7f623d1 100644
--- a/plugins/bazaar/src/components/SortMethodSelector/SortMethodSelector.tsx
+++ b/plugins/bazaar/src/components/SortMethodSelector/SortMethodSelector.tsx
@@ -50,7 +50,8 @@ export const SortMethodSelector = ({
>
-
+
+
);
diff --git a/plugins/bazaar/src/components/SortView/SortView.tsx b/plugins/bazaar/src/components/SortView/SortView.tsx
index 46f4c64c42..e0b591732e 100644
--- a/plugins/bazaar/src/components/SortView/SortView.tsx
+++ b/plugins/bazaar/src/components/SortView/SortView.tsx
@@ -27,7 +27,12 @@ import { BazaarProject } from '../../types';
import { bazaarApiRef } from '../../api';
import { Alert } from '@material-ui/lab';
import SearchBar from 'material-ui-search-bar';
-import { sortByDate, sortByMembers, sortByTitle } from '../../util/sortMethods';
+import {
+ sortByDate,
+ sortByMembers,
+ sortByTitle,
+ sortByDecendingTitle,
+} from '../../util/sortMethods';
import { SortMethodSelector } from '../SortMethodSelector';
import { fetchCatalogItems } from '../../util/fetchMethods';
import { parseBazaarProject } from '../../util/parseMethods';
@@ -78,7 +83,12 @@ export const SortView = (props: SortViewProps) => {
const bazaarApi = useApi(bazaarApiRef);
const catalogApi = useApi(catalogApiRef);
const classes = useStyles();
- const sortMethods = [sortByDate, sortByTitle, sortByMembers];
+ const sortMethods = [
+ sortByDate,
+ sortByTitle,
+ sortByDecendingTitle,
+ sortByMembers,
+ ];
const [sortMethodNbr, setSortMethodNbr] = useState(0);
const [openAdd, setOpenAdd] = useState(false);
const [searchValue, setSearchValue] = useState('');
diff --git a/plugins/bazaar/src/util/sortMethods.ts b/plugins/bazaar/src/util/sortMethods.ts
index d7ef71c8de..d0680949f2 100644
--- a/plugins/bazaar/src/util/sortMethods.ts
+++ b/plugins/bazaar/src/util/sortMethods.ts
@@ -35,6 +35,15 @@ export const sortByTitle = (a: BazaarProject, b: BazaarProject) => {
return 0;
};
+export const sortByDecendingTitle = (a: BazaarProject, b: BazaarProject) => {
+ if (a.title < b.title) {
+ return 1;
+ } else if (a.title > b.title) {
+ return -1;
+ }
+ return 0;
+};
+
export const sortByMembers = (a: BazaarProject, b: BazaarProject) => {
return b.membersCount - a.membersCount;
};