> ## Documentation Index
> Fetch the complete documentation index at: https://developer.box.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sorting responses

export const MultiRelatedLinks = ({sections = []}) => {
  if (!sections || sections.length === 0) {
    return null;
  }
  return <div className="space-y-8">
      {sections.map((section, index) => <RelatedLinks key={index} title={section.title} items={section.items} />)}
    </div>;
};

export const RelatedLinks = ({title, items = []}) => {
  const getBadgeClass = badge => {
    if (!badge) return "badge-default";
    const badgeType = badge.toLowerCase().replace(/\s+/g, "-");
    return `badge-${badge === "ガイド" ? "guide" : badgeType}`;
  };
  if (!items || items.length === 0) {
    return null;
  }
  return <div className="my-8">
      {}
      <h3 className="text-sm font-bold uppercase tracking-wider mb-4">{title}</h3>

      {}
      <div className="flex flex-col gap-3">
        {items.map((item, index) => <a key={index} href={item.href} className="py-2 px-3 rounded related_link hover:bg-[#f2f2f2] dark:hover:bg-[#111827] flex items-center gap-3 group no-underline hover:no-underline border-b-0">
            {}
            <span className={`px-2 py-1 rounded-full text-xs font-semibold uppercase tracking-wide flex-shrink-0 ${getBadgeClass(item.badge)}`}>
              {item.badge}
            </span>

            {}
            <span className="text-base">{item.label}</span>
          </a>)}
      </div>
    </div>;
};

export const Link = ({href, children, className, ...props}) => {
  const localizedHref = href;
  return <a href={localizedHref} className={className} {...props}>
      {children}
    </a>;
};

Where an API returns a collection of items it often supports sorting of API
responses.

Use the `sort` and `direction` query parameters to sort the collection either in
ascending or descending order.

```sh theme={null}
curl https://api.box.com/2.0/folders/0/items?sort=size&direction=DESC \
    -H "authorization: Bearer ACCESS_TOKEN"
```

<Warning>
  Not all API endpoints that return collections have support for sorting.
  Especially endpoints that use marker-based pagination often lack support for
  sorting the results.
</Warning>

## Sorting criteria

The field to sort on is defined by the `sort` query parameter. Check the API
endpoint's documentation for the possible options for this value.

<Note>
  In some APIs the `sort` field is the second criteria by which the items are
  sorted. For example for the <Link href="/reference/get-folders-id-items">`GET /folders/:id/items`</Link>
  endpoint the results are always sorted by their type first before any other
  criteria.
</Note>

## Sorting direction

The sorting direction supports two values, either `ASC` for ascending order, or
`DESC` for the reverse.

<RelatedLinks
  title="RELATED APIS"
  items={[
{ label: translate("List items in folder"), href: "/reference/get-folders-id-items", badge: "GET" }
]}
/>
