Repository: payloadcms/payload
File: test/sort/int.spec.ts (TypeScript)

Code before:
            orderableField: related.id,
            _orderable_orderableJoinField1_order: 'e4',
          },
        })
        const orderable4 = await payload.create({
          collection: orderableSlug,
          data: {
            title: 'test',
            orderableField: related.id,
            _orderable_orderableJoinField1_order: 'e2',
          },
        })
        expect(orderable2._orderable_orderableJoinField1_order).toBe('e4')
        expect(orderable4._orderable_orderableJoinField1_order).toBe('e2')
      })

      it('should sort join docs in the correct', async () => {
        related = await payload.findByID({
          collection: orderableJoinSlug,
          id: related.id,
          depth: 1,
        })
        const orders = (related.orderableJoinField1 as { docs: Orderable[] }).docs.map((doc) =>
          parseInt(doc._orderable_orderableJoinField1_order, 36),
        ) as [number, number, number]
        expect(orders[0]).toBeLessThan(orders[1])
        expect(orders[1]).toBeLessThan(orders[2])
      })
    })
  })

  describe('REST API', () => {
    beforeAll(async () => {
      await createData('posts', [
        { text: 'Post 1', number: 1, number2: 10 },
        { text: 'Post 2', number: 2, number2: 10 },
        { text: 'Post 3', number: 3, number2: 5 },
        { text: 'Post 10', number: 10, number2: 5 },
        { text: 'Post 11', number: 11, number2: 20 },
        { text: 'Post 12', number: 12, number2: 20 },
      ])
    })

    afterAll(async () => {
      await payload.delete({ collection: 'posts', where: {} })
    })

    describe('Single sort field', () => {
      it('should sort posts by text field', async () => {
        const res = await restClient
          .GET(`/posts`, {

Review comment (bug):
Using base 36 because fractional indexing keys use characters 0-9 and a-z.
Base 16 would fail for keys like '9z' (returning just 9) since 'z' is not a valid hex character.

Also changed it in other tests for cohesion, it breaks nothing.

Code after:
          data: {
            title: 'test',
            orderableField: related.id,
            _orderable_orderableJoinField1_order: 'e4',
          },
        })
        const orderable4 = await payload.create({
          collection: orderableSlug,
          data: {
            title: 'test',
            orderableField: related.id,
            _orderable_orderableJoinField1_order: 'e2',
          },
        })
        expect(orderable2._orderable_orderableJoinField1_order).toBe('e4')
        expect(orderable4._orderable_orderableJoinField1_order).toBe('e2')
      })

      it('should sort join docs in the correct', async () => {
        related = await payload.findByID({
          collection: orderableJoinSlug,
          id: related.id,
          depth: 1,
        })
        const orders = (related.orderableJoinField1 as { docs: Orderable[] }).docs.map((doc) =>
          parseInt(doc._orderable_orderableJoinField1_order, 36),
        ) as [number, number, number]
        expect(orders[0]).toBeLessThan(orders[1])
        expect(orders[1]).toBeLessThan(orders[2])
      })
    })
  })

  describe('REST API', () => {
    beforeAll(async () => {
      await createData('posts', [
        { text: 'Post 1', number: 1, number2: 10 },
        { text: 'Post 2', number: 2, number2: 10 },
        { text: 'Post 3', number: 3, number2: 5 },
        { text: 'Post 10', number: 10, number2: 5 },
        { text: 'Post 11', number: 11, number2: 20 },
        { text: 'Post 12', number: 12, number2: 20 },
      ])
    })

    afterAll(async () => {
      await payload.delete({ collection: 'posts', where: {} })
    })

    describe('Single sort field', () => {
      it('should sort posts by text field', async () => {