c# – Como ordenar uma lista de objetos através de um critério personalizado(sem order by)?

eu peço a ajuda de vocês para resolver um problema que tem me aborrecido.
Eu tenho uma lista de escalas e gostaria de classificar ela através do Status(que por sua vez é uma propriedade da entidade HorarioEscala, mas o critério não é ordem alfabética, seria assim, as escalas com status “Aguardando Atendimento” ficariam no topo da listagem, seguidas pelas de status “Em atendimento”, e por fim, as escalas com “Atendimento encerrado”, eu já pensei na possibilidade de transformar esse Status de string para Enum para poder usar a função OrderBy, porém já existem muitos registros no banco de dados e então não daria certo, enfim, preciso de ajuda com a lógica para resolver esse problema, segue uma parte do código

public async Task<IEnumerable<EscalaViewModel>> ObterPorContratadaId(string contratadaId)
        var escalas = await _escalaRepository.ObterPorContratadaId(contratadaId);
        var escalaView = new List<EscalaViewModel>();
        var cultureInfo = new CultureInfo("pt-BR");

        if (escalas != null)
            foreach (var escala in escalas)
                var dataEscala = new List<DataEscalaViewModel>();
                foreach (var itemData in escala.DataEscalas.OrderBy(x => Convert.ToDateTime(x.DataEntrada, cultureInfo)))
                    if (itemData.DataEntrada == DateTime.Now.ToString("dd/MM/yyyy"))
                        var horarioEscala = new List<HorarioEscalaViewModel>();
                        foreach (var horario in itemData.Horarios)
                            var entrada = new EntradaViewModel();
                            if (horario.Entrada != null)
                                entrada = new EntradaViewModel
                                    DataCheckIn = horario.Entrada.DataCheckIn,
                                    HoraCheckIn = horario.Entrada.HoraCheckIn,
                                    LatitudeCheckIn = horario.Entrada.LatitudeCheckIn,
                                    LongitudeCheckIn = horario.Entrada.LongitudeCheckIn

                            var saida = new SaidaViewModel();
                            if (horario.Saida != null)
                                saida = new SaidaViewModel
                                    DataCheckOut = horario.Saida.DataCheckOut,
                                    HoraCheckOut = horario.Saida.HoraCheckOut,
                                    LatitudeCheckOut = horario.Saida.LatitudeCheckOut,
                                    LongitudeCheckOut = horario.Saida.LongitudeCheckOut
                            horarioEscala.Add(new HorarioEscalaViewModel
                                Id = horario.Id,
                                TipoEscala = horario.TipoEscala,
                                MotivoDaEscala = horario.MotivoDaEscala,
                                HorarioInicio = horario.HorarioInicio,
                                HorarioFim = horario.HorarioFim,
                                Entrada = entrada,
                                Saida = saida,
                                TipoProfissional = horario.TipoProfissional,
                                ProfissionalId = horario.ProfissionalId,
                                ProfissionalUsuarioId = horario.ProfissionalUsuarioId,
                                PrestadorServicoId = horario.PrestadorServicoId,
                                NomePrestadorServico = horario.NomePrestadorServico,
                                NomeProfissional = horario.NomeProfissional,
                                AtividadeContratada = horario.AtividadeContratada,
                                Funcao = horario.Funcao,
                                Local = horario.Local,
                                Valor = horario.Valor,
                                Status = horario.Status,
                                CargoProfissional = horario.CargoProfissional,
                                RelatorioGerado = horario.RelatorioGerado

                            dataEscala.Add(new DataEscalaViewModel
                                Id = itemData.Id,
                                DataEntrada = itemData.DataEntrada,
                                DataSaida = itemData.DataSaida,
                                Horarios = horarioEscala

                if (dataEscala.Count() > 0)
                    escalaView.Add(new EscalaViewModel
                        Id = escala.Id,
                        HomeCareId = escala.HomeCareId,
                        PacienteId = escala.PacienteId,
                        DataEscalas = dataEscala



        return escalaView;

time complexity – Examples of higher order algorithms ($mathcal{O}(n^4)$ or larger)

In most computer science cirriculums, students only get to see algorithms that run in very lower time complexities. For example these generally are

  1. Constant time $mathcal{O}(1)$: Ex sum of first $n$ numbers
  2. Logarithmic time $mathcal{O}(log n)$: Ex binary searching a sorted list
  3. Linear time $mathcal{O}(n)$: Ex Searching an unsorted list
  4. LogLinear time $mathcal{O}(nlog n)$: Ex Merge Sort
  5. Quadratic time $mathcal{O}(n^2)$: Ex Bubble/Insertion/Selection Sort
  6. (Rarely) Cubic time $mathcal{O}(n^3)$: Ex Gaussian Elimination of a Matrix

However it can be shown that
mathcal{O}(1)subset mathcal{O}(log n)subset ldots subset mathcal{O}(n^3)subset mathcal{O}(n^4)subsetmathcal{O}(n^5)subsetldotssubset mathcal{O}(n^k)subsetldots

so it would be expected that there would be more well known problems that are in higher order time complexity classes, such as $mathcal{O}(n^8)$.

What are some examples of algorithms that fall into these classes $mathcal{O}(n^k)$ where $kgeq 4$?

abstract algebra – Show the order of the Kernel of a morphism between groups

Consider $G_n={ overline{x}inmathbb{Z}/nmathbb{Z}; gcd(x,n)=1 }$, and $q$ an odd prime number.

For all $xin mathbb{Z}$, $overline{x}$ represents, in this question, the class of $x$ modulo $q^alpha$, and let’s use the notation $dot{x}$ for the class of $x$ modulo $q$ and consider the morphism of groups
Psi : G_{q^alpha} &rightarrow G_q \
overline{x}&mapsto dot{x}

Prove that $|KerPsi|=q^{alpha-1}$ (with $|KerPsi|$ the notation for order).

This question is a step by step to prove that $G_{q^alpha}$ is cyclic, but I can’t solve this part.

magento2 – Order invoice in checkout

When we are in checkout I can’t find the location where is created the invoice from the order.

I’ve manage to handle my custom invoice when we save the order in the admin. Now I need to do it in the checkout.

In admin in MagentoSalesControllerAdminhtmlOrderInvoiceSave there is a $invoice = $this->invoiceService->prepareInvoice($order, $invoiceItems);

I’m looking for the checkout version location of this treatment.

php – Order posts by hour with ACF and Timber (TWIG)

First of all I use ACF and Timber (TWIG).

I’m trying to create a calendar with a classification by year, month and hour.

I created a custom ACF field : event_date and an another field for start time event_hour_start

How I can order posts by hour for each month please ?


  • November
    • First event – 14:00
    • Second event – 16:00
  • December
    • First event – 11:00
    • Second event – 12:00


$events = Timber::get_posts(array(
    'post_type' => 'events',
    'meta_key'  => 'event_date',
    'orderby'   => 'meta_value_num',
    'order'     => 'DESC'

$events_list = array();

if($events) {
    foreach($events as $event) {
        $date = get_field('event_date', $event->ID, false);
        $hour_start = get_field('event_hour_start', $event->ID, false);
        $hour_end = get_field('event_hour_end', $event->ID, false);

        $date = new DateTime($date);

        $year = $date->format('Y');
        $month = $date->format('F');

        $events_list($year)($month)() = array($event, $date, $hour_start, $hour_end);

$context('events_list') = $events_list;


{% for year, years in events_list %}
    <p>Year : {{ year }}</p><br>
    {% for month, months in years %}
        <p>Month : {{ month }}</p>
        {% for event, events in months %}
            <p>{{ events(0).post_title }}</p><br>
        {% endfor %}
    {% endfor %}
{% endfor %}

No simple group of order 720, again

In his Notes on Group Theory, 2019 edition (http://pdvpmtasgaon.edu.in/uploads/dptmaths/AnotesofGroupTheoryByMarkReeder.pdf p. 83 and ff.)
Mark Reeder gives a proof of the non-existence of simple groups of order 720.

Here : (No simple group of order 720 ) I asked for a clarification about a statement at the beginning of the proof and I got it. (Thanks again to David A. Craven.)

I have another problem, perhaps more serious, at the end of the proof. M. Reeder proves that if $G$ is a simple group of order 720, if $s$ is an involution (element of order 2) of $G$, then $C_{G}(s)$ is a Sylow 2-subgroup of $G$ and that if $s$ and $t$ are two differents involutions of $G$, then $C_{G}(s)$ and $C_{G}(t)$ are different. So far, so good. A little further, M. Reeder says : “Since $s$ is contained in just one Sylow 2-subgroup, namely $C_{G}(s)$ (…)”. I don’t understand how that can be deduced from what precedes.

I must say that I am skeptical about the possibility of proving this in the frame of M. Reeder’s proof, for the following reason. It seems that, after proving that (for a simple group $G$ of order 720), $G$ has exactly ten Sylow 3-subgroups, that these Sylow 3-subgroups are non-cyclic and intersect pairwise trivially, M. Reeder derives a contradiction from only the following properties :

s1 : $G$ is a group (I don’t say “simple group”) of order 720 ;

s2 : $G$ has exactly ten Sylow 3-subgroups ;

s3 : these Sylow 3-subgroups are non-cyclic ;

s4 : these Sylow 3-subgroups intersect pairwise trivially ;

s5 : $G$ has no element of order 6 ;

s6 : every involution of $G$ normalizes at least two Sylow 3-subgroups of $G$ ;

s7 : $G$ has several Sylow 2-subgroups.

(M. Reeder uses another property to prove that some given subgroups of $G$ are isomorphic to $Q_{8}$, but he notes that this fact plays no real role.)

Now, properties s1 to s7 are not contradictory, because the group $M_{10}$ possesses them. (By the way, properties s1 to s6 are not independent : s3 can be deduced from s1, s2 and s5, using the N/C lemma.)

My question is : do you see how the statement “$s$ is contained in just one Sylow 2-subgroup, namely $C_{G}(s)$” can be proved in the frame of Mark Reeder’s proof ? Thanks in advance.

Note : I wrote up Mr. Reeder’s proof by breaking it down into simple elements and indicating, for each element, the minimum hypotheses. If anyone is interested, I can post this work here. I can also post a proof that $M_{10}$ possesses properties s1 to s7.

magento2 – Magento 2: “Back” Link from View Order to Custom Grid

You can do this by plugin.

Create this class:

namespace NameSpaceModuleNamePluginSalesBlockAdminhtmlOrder;

use MagentoSalesBlockAdminhtmlOrderView as OrderView;
use MagentoFrameworkUrlInterface;
use MagentoFrameworkAuthorizationInterface;

class View
    /** @var MagentoFrameworkUrlInterface */
    protected $_urlBuilder;

    /** @var MagentoFrameworkAuthorizationInterface */
    protected $_authorization;

    public function __construct(
        UrlInterface $url,
        AuthorizationInterface $authorization
        $this->_urlBuilder = $url;
        $this->_authorization = $authorization;

    public function beforeSetLayout(OrderView $view)
        $url = $this->_urlBuilder->getUrl('your_route', ('order_id' => $view->getOrderId()));
        $view->updateButton('back', 'onclick', 'setLocation('' . $url . '')');

And in your etc/adminhtml/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="MagentoSalesBlockAdminhtmlOrderView">
        <plugin name="your_module_adminhtml_order_view_add_button" type="NameSpaceModuleNamePluginSalesBlockAdminhtmlOrderView" sortOrder="10" />

This should work.


You could do this:

public function beforeSetLayout(OrderView $view) {
    $param = $view->getRequest()->getParam('redirect_back'); //you can even pass your route and use it in codntion then build the back url accordingly.
    if ( $param == '1') {
        $url = $this->_urlBuilder->getUrl('your_route', ('order_id' => $view->getOrderId()));
        $view->updateButton('back', 'onclick', 'setLocation('' . $url . '')');

Now, in your custom grid build URL with the redirect_back/1. So your full grid URL should be like this:


networking – Do I still need to modify PolKit in order to add a new Wifi connection without root?

After googling this problem, it appears (as of 7 YEARS ago) that the only way to allow users to change wifi networks is to modify PolKit (solution 1, solution 2).

Is this still the case with Ubuntu 20.04, without having to install further packages? Hard to believe that Ubuntu hasn’t made this more user-friendly yet over the last 7 years.