@param Workspace $workspace
@param string    $orderedBy
@param string    $order

@return array
184639
public function getTeamsByWorkspace(Workspace $workspace, $orderedBy = 'name', $order = 'ASC')
    {
        return $this->teamRepo->findBy(['workspace' => $workspace], [$orderedBy => $order]);
    }
56888
protected function getOrderBys($order)
    {
        $separatedOrders = [$order];

        if ($this->isMultiOrderQuery($order)) {
            $separatedOrders = explode(',', $order);
        }

        return $separatedOrders;
    }
442196
public function findGroupsByWorkspaces(array $workspaces, $executeQuery = true)
    {
        $dql = '
            SELECT g
            FROM Claroline\CoreBundle\Entity\Group g
            LEFT JOIN g.roles wr WITH wr IN (
                SELECT pr from Claroline\CoreBundle\Entity\Role pr WHERE pr.type = :type
            )
            LEFT JOIN wr.workspace w
            WHERE w IN (:workspaces)
            ORDER BY g.name
       ';
        $query = $this->_em->createQuery($dql);
        $query->setParameter('workspaces', $workspaces);
        $query->setParameter('type', Role::WS_ROLE);

        return $executeQuery ? $query->getResult() : $query;
    }
1275551
public function findAllNonPersonalWorkspacesBySearch(
        $search,
        $orderedBy = 'name',
        $order = 'ASC',
        User $user = null
    ) {
        $isAdmin = $user ? $user->hasRole('ROLE_ADMIN') : false;

        $qb = $this->createQueryBuilder('w');
        $qb->select('w')
          ->join('w.organizations', 'o')
          ->leftJoin('o.administrators', 'a')
          ->where('NOT EXISTS (
              SELECT u
              FROM Claroline\CoreBundle\Entity\User u
              JOIN u.personalWorkspace pw
              WHERE pw = w
          )')
          ->andWhere($qb->expr()->orX(
            $qb->expr()->like('UPPER(w.name)', '?1'),
            $qb->expr()->like('UPPER(w.code)', '?1')
          ))
          ->setParameter(1, "%{$search}%");

        if (!$isAdmin) {
            $qb->andWhere('a.id = ?2')->setParameter(2, $user->getId());
        }

        $qb->orderBy("w.{$orderedBy}", $order);

        return $qb->getQuery()->getResult();
    }
211558
public function getRolesByWorkspace(
        Workspace $workspace,
        $search = '',
        $orderedBy = 'id',
        $order = 'ASC'
    ) {
        if (empty($search)) {
            return $this->roleRepo->findByWorkspace($workspace, $orderedBy, $order);
        } else {
            return $this->roleRepo->findByWorkspaceAndSearch(
                $workspace,
                $search,
                $orderedBy,
                $order
            );
        }
    }
18257
public static function findAllArray($condition = [],$orderBy = []) {
        return self::find()->where($condition)->asArray()->orderBy($orderBy)->all(static::getDb());
    }
949337
public function getTeamsByWorkspace(
        Workspace $workspace,
        $orderedBy = 'name',
        $order = 'ASC',
        $executeQuery = true
    )
    {
        return $this->teamRepo->findTeamsByWorkspace(
            $workspace,
            $orderedBy,
            $order,
            $executeQuery
        );
    }
964636
public function getTabsScheduledForInsert(Workspace $workspace)
    {
        $scheduledForInsert = $this->om->getUnitOfWork()->getScheduledEntityInsertions();
        $res = [];

        foreach ($scheduledForInsert as $entity) {
            if ('Claroline\CoreBundle\Entity\Tab\HomeTab' === get_class($entity)) {
                if ($entity->getWorkspace()->getCode() === $workspace->getCode()) {
                    $res[] = $entity;
                }
            }
        }

        return $res;
    }
1139192
final public static function all($orderBy = ['createdAt' => 'DESC'], bool $withTrash = false)
    {
        $criteria = self::criteriaWithSoftDelete([], $withTrash);
        return static::getRepository()
            ->findBy($criteria, $orderBy);
    }
1346896
public function getUnpublishedNodes(Workspace $workspace)
    {
        if ($workspace->getBaseWorkspace() === null) {
            return [];
        }

        $nodeData = $this->nodeDataRepository->findByWorkspace($workspace);
        $unpublishedNodes = [];
        foreach ($nodeData as $singleNodeData) {
            /** @var NodeData $singleNodeData */
            // Skip the root entry from the workspace as it can't be published
            if ($singleNodeData->getPath() === '/') {
                continue;
            }
            $node = $this->nodeFactory->createFromNodeData($singleNodeData, $this->createContext($workspace, $singleNodeData->getDimensionValues()));
            if ($node !== null) {
                $unpublishedNodes[] = $node;
            }
        }

        $unpublishedNodes = $this->sortNodesForPublishing($unpublishedNodes);

        return $unpublishedNodes;
    }
283683
public function sortByArrayKeys(array $orderBy)
    {
        $result = $this->target;

        if ($orderBy) {
            $ordered = [];

            foreach ($orderBy as $key) {
                if (array_key_exists($key, $result)) {
                    $ordered[$key] = $result[$key];
                    unset($result[$key]);
                }
            }

            $result = $ordered + $result;
        }

        return $result;
    }
1237688
protected function isOrdered(array $ordered)
    {

        // validate fields by exist in tables

        foreach ($ordered as $table => $sort) {

            // load model metaData

            if ($this->isModel($table) === true) {
                $model = (new Manager())->load($table, new $table);

                // check fields of table

                $this->validColumns($model->getModelsMetaData(), array_keys($sort), $table, $model);

                // check sort clause

                $sort = array_map('strtolower', $sort);

                if (empty($diff = array_diff(array_values($sort), $this->sort)) === false) {
                    throw new ExceptionFactory('Column', ['ORDER_TYPES_DOES_NOT_EXISTS', $diff]);
                }

                if (empty($diff = array_diff($sort, $this->sort)) === false) {
                    throw new ExceptionFactory('Column', ['ORDER_TYPES_DOES_NOT_EXISTS', $diff]);
                }

                $this->fields[$this->cast][$model->getSource()] = $sort;
            }
        }

        return true;
    }
977886
public function getCalendarViewArray(OrderCollection $orderCollection)
    {
        $windows  = $this->findForSelectWindowForOrderCollection($orderCollection);
        $slots     = HubWindow::getSlots();

        foreach ($windows as $window)
        {
            $hour = $window->getStartTime()->format('H:i');
            $date = $window->getStartTime()->format('Y-m-d');

            if (array_key_exists($hour, $slots) && array_key_exists($date, $slots[$hour]))
            {
                $slots[$hour][$date] = $window; //->getStartTime()->format(\DateTime::ATOM);
            }
        }

        // \HarvestCloud\CoreBundle\Util\Debug::show($slots);

        return $slots;
    }
409304
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
    {
        $criteria = array_merge($criteria, array("deleted" => false));

        return parent::findBy($criteria, $orderBy, $limit, $offset);
    }
75606
public function getCategoriesByUser(
        User $user,
        $orderedBy = 'order',
        $order = 'ASC',
        $executeQuery = true
    )
    {
        return $this->categoryRepo->findCategoriesByUser(
            $user,
            $orderedBy,
            $order,
            $executeQuery
        );
    }
651956
static public function listSortForMany($list, $orderBy)
    {
        if (!is_array($list) || !$orderBy) {
            return $list;
        }

        if (is_string($orderBy)) {
            $orderBy = explode(',',$orderBy);
        }

        list($key,$sort) = explode(' ',reset($orderBy));

        $arr = [];
        foreach ($list as $row) {
            $arr[$row[$key]][] = $row;
        }

        if ($sort == "desc") {
            krsort($arr);
        }else{
            ksort($arr);
        }

        array_shift($orderBy);

        if (!empty($orderBy)) {
            foreach ($arr as &$row) {
                $row = self::listSortForMany($row,$orderBy);
            }
        }

        return (count($arr) >= 1) ? array_merge(...array_values($arr)) : $arr;
    }
201826
public function orderBy($sort, $order = null)
    {
        return $this->add('orderBy', $sort . ' ' . (! $order ? 'ASC' : $order), false);
    }