# indexOf() but sorted

**URL:** <https://forum.getkirby.com/t/indexof-but-sorted/25489>\
**Category:** Questions\
**Tags:** v3\
**Created:** [May 13, 2022, 1:16pm UTC](https://forum.getkirby.com/t/indexof-but-sorted/25489 "2022-05-13T13:16:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jwssnr](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jwssnr/32/11727_2.png) [@jwssnr](https://forum.getkirby.com/u/jwssnr)\
**Post date:** [May 13, 2022, 1:16pm UTC](https://forum.getkirby.com/t/indexof-but-sorted/25489/1 "2022-05-13T13:16:58Z")

</div>

Hey: I’m building a slider with a counter.  
But the images are manually sorted and filtered with `->sortBy('sort')`  
Now if I use `->indexOf()` I get the index of where an item is placed in the alphamumeric order.  
How can I resolve this?

```auto
<?php $filtered = $page->images()->filterBy('skip', false) ?>
<?php $amount = $filtered->count() ?>
<?php $items = $filtered->sortBy('sort') ?> 
<?php foreach($items as $item): ?>

	<p class="counter"><?= $item->indexOf() + 1 ?>/<?= $amount ?></p>

<?php endforeach ?>

```

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [May 13, 2022, 2:14pm UTC](https://forum.getkirby.com/t/indexof-but-sorted/25489/2 "2022-05-13T14:14:50Z")

</div>

You have to pass the collection as argument

```auto
 $item->indexOf($items)

```

---

<div class="post-metadata">

**Author:** ![jwssnr](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jwssnr/32/11727_2.png) [@jwssnr](https://forum.getkirby.com/u/jwssnr)\
**Post date:** [May 13, 2022, 2:35pm UTC](https://forum.getkirby.com/t/indexof-but-sorted/25489/3 "2022-05-13T14:35:32Z")

</div>

Is there anywhere beer donation button for you guys? I’m so happy having such a great support.
