Ordering a sequence of objects by type The below code takes an incoming sequence of objects, checks each object's type and then yields the object in a specific order.  This is all taking place in an active pattern.  As I am still new to F#, I would like to know if there is a better or more efficient way of accomplishing this task.

    type ArticleObj = 
    | Submission
    | Photos
    | ReviewRating
    | BusinessReviewRating
    | ArticleTag


let (|OrderArticleObj|_|) (objSeq : seq&lt;obj&gt;) =

    // Create DU array
    let articleParts = [| 
                        Submission; Photos; ReviewRating; 
                        BusinessReviewRating; ArticleTag 
                    |]

    // create ordered array of objects
    let orderedSeq = seq{
                for row in articleParts do
                    for row2 in objSeq do
                        match row with
                        | Submission -&gt; 
                                        let isValid =
                                            match row2 with
                                            | :? ArticleSubmission as Sub -&gt; true
                                            | _ -&gt; false

                                        if isValid
                                        then
                                            yield row2
                        | Photos -&gt;
                                    let isValid =
                                            match row2 with
                                            | :? seq&lt;Photos&gt; as Photo -&gt; true
                                            | _ -&gt; false

                                    if isValid
                                    then
                                        yield row2
                        | ReviewRating -&gt;
                                            let isValid =
                                                match row2 with
                                                | :? ArticleReviewRating as RevRating -&gt; true
                                                | _ -&gt; false

                                            if isValid
                                            then
                                                yield row2
                        | BusinessReviewRating -&gt;
                                                    let isValid =
                                                        match row2 with
                                                        | :? BusinessReviewRating as BizRev -&gt; true
                                                        | _ -&gt; false

                                                    if isValid
                                                    then
                                                        yield row2
                        | ArticleTag -&gt;
                                        let isValid =
                                            match row2 with
                                            | :? seq&lt;ArticleTags&gt; as ArtTag -&gt; true
                                            | _ -&gt; false

                                        if isValid
                                        then
                                            yield row2
            }

    if not (Seq.isEmpty orderedSeq)
    then Some(orderedSeq) else None
You could define a sorted list of the types and use that to sort the input. Here's what a function that does that would look like.

let sortArticles : seq&lt;obj&gt; -&gt; seq&lt;obj&gt; =
    let sorted =
        [
            typeof&lt;ArticleSubmission&gt;
            typeof&lt;seq&lt;Photos&gt;&gt;
            typeof&lt;ArticleReviewRating&gt;
            typeof&lt;BusinessReviewRating&gt;
            typeof&lt;seq&lt;ArticleTags&gt;&gt;
        ]
    Seq.sortBy (fun o -&gt; sorted |&gt; List.findIndex ((=) (o.GetType())))