# Fairly simple PHP sorting Dilemma

**URL:** <https://forum.kirupa.com/t/fairly-simple-php-sorting-dilemma/236123>\
**Category:** Uncategorized\
**Created:** [August 17, 2007, 12:51pm UTC](https://forum.kirupa.com/t/fairly-simple-php-sorting-dilemma/236123 "2007-08-17T12:51:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dewey](https://avatars.discourse-cdn.com/v4/letter/d/919ad9/32.png) [@dewey](https://forum.kirupa.com/u/dewey)\
**Post date:** [August 17, 2007, 12:51pm UTC](https://forum.kirupa.com/t/fairly-simple-php-sorting-dilemma/236123/1 "2007-08-17T12:51:28Z")

</div>

Hey People,

I know this has got to be easy, but all I can find on “comparing custom objects” on google is comparing a custom object with ==

What I have is this simple class…

```php
<?php

class PlayerData
{

    var $id;
    var $w_pct;
    
    function PlayerData($id)
    {
        $this->id = $id;
    }
    
    function set_id($id)
    {
        $this->id = $id;
    }
    
    function get_id()
    {
        return $this->id;
    }

    function set_w_pct($w_pct)
    {
        $this->w_pct = $w_pct;
    }
    
    function get_w_pct()
    {
        return $this->w_pct;
    }
}

?>

```

I am going to have an array of these objects and I want to be able to use a simple array sort, but I want the objects to be sorted by their w\_pct (winning percentage). What is the easiest way to do this? I come from Java where I would simply implement comparable, but I am fairly new to PHP and quite sure it doesn’t exist…

Thanks!

–d
